Hello, could someone point me in the right direction on this please....Not spent long coding in any language, but im getting somewhere using Unity3D.
Basically, i got a simple 2D game that Ascends upwards when the playerobject hits particle objects...this all works fine. Now i need to add a descending script (So that the camera stops following the player object when it starts to descend). How would i go by doing this in C#. This is all so i can run this script.
Basically when the player is out of camera view, the game ends, But my problem is that my camera is constantly following my player and i have no idea how to release it once the playerobject descends...Any ideas?
Basically, i got a simple 2D game that Ascends upwards when the playerobject hits particle objects...this all works fine. Now i need to add a descending script (So that the camera stops following the player object when it starts to descend). How would i go by doing this in C#. This is all so i can run this script.
Code:
//Update camera position if the player has climbed and if the player is too low: Set gameover.
float currentCameraHeight = transform.position.y;
float newHeight = Mathf.Lerp(currentCameraHeight, playerHeight, Time.deltaTime * 10);
if (playerTrans.position.y > currentCameraHeight)
{
transform.position = new Vector3(transform.position.x, newHeight, transform.position.z);
}else{
//Player is lower..maybe below the cameras view?
if (playerHeight < (currentCameraHeight - 10))
{
GameOver();
}
}
Basically when the player is out of camera view, the game ends, But my problem is that my camera is constantly following my player and i have no idea how to release it once the playerobject descends...Any ideas?