I need get that my camera follow my character always leaving a margin of height above the character. I want this event is active after to give a click.
An example to follow is the game of “Into the Circle”, when the player it’s launched, the camera follows the character always leaving a margin of height between the character and the camera.
See the video:
This is my code:
if (Input.GetMouseButtonDown (0)) {
// This does not give me the result I want
camera.transform.position = new Vector3 (0, player.transform.position.y / 2, -10);
}
}
People might comment on how the lerp I am doing is wrong, but it isnt, it just might not give the result you are expecting. You can look online for different ways to use lerp, such as here Using Vector3.Lerp() correctly in Unity — One Man's Trash is Another Man's Blog
Sorry if I misstyped something or the logic is wrong. Writing code on a tablet is painful.