Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

2D: Rotating the camera vs. everything else.

Discussion in 'Scripting' started by Chimaker, Aug 20, 2014.

  1. Chimaker

    Chimaker

    Joined:
    Aug 20, 2014
    Posts:
    2
    I'm writing a 2D game that requires the entire world to rotate around the center of the screen (the camera). I would assume that the simplest way to achieve this effect would be to simply rotate the camera, but I couldn't seem to find a way to do that.

    Without rotating the camera, the only way that I can think of to rotate the world is to literally rotate every object around whatever point happens to be the center of the screen at the time, which would be very resource intensive, especially since it will be almost always rotating.

    Is there an easy way to rotate the camera, or perhaps some other work-around I'm not thinking of?

    I am using the free version of Unity, and will also be changing the direction of gravity based on the camera angle (which I THINK should be easy to do regardless of the method, but I thought I should state it in case anyone had any really weird ideas that would stop that from working for some reason...).

    I have almost no experience with Unity, so I apologize if this is a stupid question, or I'm missing something obvious.

    Thank you for your time.
     
  2. Fluzing

    Fluzing

    Joined:
    Apr 5, 2013
    Posts:
    815
    Camera.main.transform.rotation

    You can change that to rotate the camera.
     
    Chimaker likes this.
  3. Chimaker

    Chimaker

    Joined:
    Aug 20, 2014
    Posts:
    2
    Oh. That did work. I needed to change the Z. I'm an idiot.

    Thank you.