- Home /
How can i prevent the camera from goin down the y axis (othographic Doodle jump camera)
Hi all
im working on a 2d vertical platformer for a study project. With this simple code i control the camera
transform.position.y = player.transform.position.y
Now i only want the camera to go up, so i can put a collider under the camera that kills the player.
How can i prevent the camera from goin down the y axis?
Answer by Tijs · Dec 29, 2012 at 05:34 PM
if the heigt of the target exceeds the height of the camera the camera will follow. This worked perfectly, thanks alot!
var target:Transform;
function Update () { if(target.transform.position.y > Camera.main.transform.position.y) { Camera.main.transform.position.y = target.transform.position.y; } }
Your answer
![](https://koobas.hobune.stream/wayback/20220613085918im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Lock main camera on x-axis 2 Answers
ScreenToWorldPoint not accurate 0 Answers
Camera moving in one direction? 2 Answers
How do I lock Y Axis movement for Parented Camera? 3 Answers