- Home /
Stoping camera when character is falling.
Well my character goes upwards for my game. Camera is following it there is no problem. But when character is falling, I want to stop camera. I just need to spot maximum reached height
highestPosition =
Pos = target.position.y;
if (highestPosition > Pos) { GetComponent ().enabled = false;}
How can i detect highest position?
so in your game. the camera follows the player but if they fall, it stays at the highest position? so if they fall its game over?
Answer by Scoutas · Feb 01, 2017 at 12:12 AM
You have variables highestPosition
, currentPosition
.
Now, I would have a check like this
if(currentPosition > highestPosition){
highestPosition = currentPosition;
}
And then, I would just make the camera follow the highest position. If the player keeps climbing up - the camera climbs together with him. If he falls, the camera stays at the highest reached position.
Thank you. But my problem is that I can't deteck highest reached positin. I don't know how to do that.
Err, what @Scoutas said was exactly what you wanted.
float yPos = target.position.y;
if (yPos > highestPos)
{
highestPos = yPos;
//$$anonymous$$ove Camera
}
else
{
//Don't move Camera
}
Your answer
Follow this Question
Related Questions
Why Does My Object Change Position During Update? 0 Answers
Remove object based on its position alone 1 Answer
Collide edge of object with the edge of the screen 0 Answers
Camera rotation around player while following. 6 Answers
How to segment a number line of game objects between two points dynamically? 1 Answer