- Home /
Answer by Theacesofspades · Dec 28, 2012 at 05:34 PM
This is untested so it may contain something wrong but try something like this.
var target : Transform;
var height : float;
var lastheight : float;
function Start ()
}
height = target.transform.position.y;
lastheight = target.transform.position.y;
}
function Update ()
{
height = transform.position.y
if (height > lastheight)
transform.position.y = height;
lastheight = transform.position.y
}
This code goes on the camera. You need to drag in the target object in the editor.
Great! I see how this method can work. when i put it on, my camera wont move at all. maybe height and lastheight should be sepperatly defined?
Answer by Tijs · Dec 28, 2012 at 09:30 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
Follow this Question
Related Questions
How do I lock Y Axis movement for Parented Camera? 3 Answers
camera transform not working when getting axis position 3 Answers
Parented Camera is locked to character animation 0 Answers
How can i prevent the camera from goin down the y axis (othographic Doodle jump camera) 1 Answer
Lock main camera on x-axis 2 Answers