Hey guys, I am trying to code a camera follow script that only follows the player on the Y axis which I have achieved, what I am struggling on is how to make it so the camera only follows the player if he is going up, so if he falls the camera stays still and he is able to fall of the screen. There must be a simple answer but I just cant see it. Any help would be greatly appreciated.
Thanks in advanced.
if( YourPlayer.transform.position.y > YourCamera.transform.position.y)
{
YourPlayer.transform.position.y = YourCamera.transform.position.y;
}
Or something like that, right ?
You can also store the previous pos of the player and update your cam only if its current y pos is > previous y pos