Question by
S1lenced7 · Sep 09, 2019 at 07:07 PM ·
rotationquaternions
Changing existing quaternion to account for relative axis rotation
Hi i'm quite new to Unity and my Knowledge about Quaternions is somewhat limited. Regardless, I've got a piece of code that will "point" my game object to a Vector3 (mouse raycast).
//find the vector pointing from our position to the target
Vector3 direction = (target - transform.position).normalized;
//rotation required to look at target
Quaternion look_rotation = Quaternion.LookRotation(direction);
// Only rotate along the Y axis -- perhaps a different solution???
look_rotation.x = 0f;
//rotate over time according to speed until we are at the required rotation
return Quaternion.Slerp(transform.rotation, look_rotation, Time.deltaTime * roation_authority);
However, i would like my object to gently tilt/bank as it rotates. Here is where i'm at a loss. I need to base the tilt on the (signed)angular distance between the rotations (tilt left when turning left , tilt more the larger the angle, don't surpass 60 degree tilt). And then need to add this rotation to the previously calculated rotation.
Some pointers on how to go about this?
Comment
Your answer