Hey everybody !
I am trying to get an orbit of my camera around a moving object only using code, I would like to use transform.RotateAround as it seems it is a pretty straight forward solution
For now I have this :
void LateUpdate()
{
MouseInput = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y"));
Vector3 offset = new Vector3 (cameraPivot.position.x + cameraOffset.x, cameraPivot.position.y + cameraOffset.y, cameraPivot.position.z + cameraOffset.z);
transform.position =offset;
transform.RotateAround(cameraPivot.position, cameraPivot.up, MouseInput.x);
transform.RotateAround(cameraPivot.position, cameraPivot.right, MouseInput.y);
}
The camera does follow the object when moving, but the rotation is happening on the camera itself( like its looking around ) but not around the object.
Note that this is not happening when I dont update the transform.position of the camera, and the camera is orbiting correctly the object in that case.
any idea what could cause that ?
Thank you !