- Home /
Scrolling camera in Shoot 'em up
Alright, this has been bugging me for a while. In a platformer, a scrolling camera is easy to implement, just have the camera slowly move to the left(or right) and force the player within the camera's viewpoints using camera.ViewportToWorldPoint.
But in a top-down shoot 'em up, not that simple, because the player needs to move with the camera. That is, if the player is situated in the upper left corner of the screen they will stay there, even when they aren't moving, the camera will not "leave them behind".
Now we could use ViewportToWorldPoint to calculate and move the player to a new appropriate worlpoint relative to the camera, but I would think that would confuse the Physics system, since the player would be "warping" to different screen coordinates, and we would rather use the physics system if possible.
Would it be better to scroll the player somehow, and have the camera follow from above?
Answer by Ashkan_gc · Feb 13, 2010 at 05:59 AM
you can use parenting. make the player parent of your camera and then when you move the player with physics or translate or set it's position in any other way. the camera will move with it and always stays in the same distance. also you can set something like this in camera's LateUpdate function in a script.
transform.position = other.transform.position+offset;
other is a public gameObject that you should set it to your player and offset is a Vector3 that should be public too and you should set it to the offset that you want. in this way you can make the camera behave like what you want.
Your answer
Follow this Question
Related Questions
Camera Height (y) 2 Answers
Making a bubble level (not a game but work tool) 1 Answer
Moving forward in 3D 1 Answer