- Home /
Move camera certain distance away from object, but keep object centered (with specific camera rotation)
I have a character of which the camera should be positioned so that it:
– has a certain distance from the character object (e.g. 10 units)
– has a specific rotation (e.g. 45° on the x-axis)
– keeps the object centered on the screen
My attempt so far:
public GameObject camera;
public GameObject character;
private Vector3 distanceToChar = new Vector3(10f, 10f, 10f);
void Update() {
camera.transform.position = character.transform.position + distanceToChar
}
However, then, the object isn't centered on the screen. How can I do so?
Thanks in advance!
Comment