- Home /
Camera Distance
How would I go about setting the camera distance from the player and the camera from height.
Comment
Answer by morbidcamel · Jan 15, 2014 at 06:28 AM
Have a look at the character controller. To do the math should be simple enough... Should be simple enough - something like:
var distance = (camera.transform.position - player.transform.position).magnitude;
var height = (camera.transform.position - player.transform.position).y;
So asumingyou have a field called offset --
public Vector3 offset = new Vector3(0,5,-4);
public float speed = 0.5f;
you can do a --
camera.position = Vector3.Lerp(camera.position, player.transform.position + offset, Time.deltaTime*speed);
Your answer
![](https://koobas.hobune.stream/wayback/20220613130451im_/https://answers.unity.com/themes/thub/images/avi.jpg)