- Home /
How do I move my camera along its local x and y axes to look at a position?
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?
Thank you!
Simple solution: Put your camera inside an empty game object that is oriented in the proper axis. Camera stays looking where it needs to, parent object moves.
Answer by IvovdMarel · Mar 20, 2017 at 02:56 AM
Using KISS principles, you could parent your Camera to another GameObject, that is placed on your floor. When you select the unit, move the parent GameObject to the selected unit. The camera offset remains :)
HAHA nice, literally posted my comment and your answer at the EXACT SA$$anonymous$$E moment :P
Your answer
Follow this Question
Related Questions
translate a point between two cameras 0 Answers
Smooth camera shift, Lerp? SmoothShift? 2 Answers
Camera gets stuck when cursor is locked 0 Answers
Issue with my camera controls 0 Answers