I’m making a racing game camera.
I have the “Vehicle” wich moves arround and I have a camera following the vehicle. This camera is held by an empty gameObject wich I’ll name CameraHolder.
In the Hierarchy the Camera is son of the CameraHolder, wich is son of the Vehicle.
- Vehicle
- CameraHolder
- Camera
- CameraHolder
The camera is always at the same distance from the CameraHolder and I rotate the cameraHolder using mouse.
angleX += Input.GetAxis("Mouse X")*sensitivity;
angleY += Input.GetAxis("Mouse Y")*sensitivity;
var wantedRotation : Quaternion = Quaternion.Euler(-angleY, angleX, 0);
transform.rotation = toGlobal(wantedRotation);
The problem is that I want angles to be relative to the Vehicle’s rotation so I need to transform the local Quaternion wantedRotation generated from angles, to global Quaternion using the Vehicle rotation quaternion in some way.
I need some way of toGlobal() function.
Probably, if it’s not possible I’ll need to work on Euler Angles or Directions.