I'm working on a tile-based strategy game, and my orthographic camera is at an angle to the field, which is flat against the y-axis.
I have two ways of moving my camera: - I can move it manually, in which case it moves along its local x and y axes. This works well because I can move it based on its current position and rotation. - I can focus on a unit. This is where I'm having issues.
When I select a unit, I'm going to move the camera to center on that unit. To do this, I'd like it to move so its centered on that unit without moving the camera on its local z-axis. (This is important to avoid clipping with the environment on large maps.) This way it will have the same behavior as when I move it manually.
I've included a screenshot of the editor view with the camera selected, as an example: https://i.imgur.com/Un8GZ5f.png
Does anyone have an ideas?
Answer by Time_Flys
Mar 20 at 10:21 PM
Create an empty game object that has it's rotation zeroed out. Make your Camera a child of the newly created empty game object. Now move the empty game object, which will in turn move the camera. You should no longer have to adjust the Z to shift the camera on the X and Y no matter what angle your camera is at.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
71 People are following this question.
Main Camera movement controlling others, rendering to texture
Finding the angle at which the edges of a camera shoot out
camera movements very slow, why!? :)
How can you make a FPS controller camera "fly"?
Mouse Camera Control