- Home /
Steering using Quarternion.LookRotation.
im working on an arcade flight sim which doesnt have very realistic flight dynamics for the ai, and i need some help with the aircraft ai.
current setup
Im using the following to steer the aircraft. with an empty game object called waypoint being positioned just behind the target.
targetHeading = waypoint.transform.position - mytransform.position;
mytransform.localRotation= (Quaternion.Slerp(mytransform.localRotation,Quaternion.LookRotation(targetHeading),rotationspeed * Time.deltaTime));
problem
my problem is that while Quaternion.LookRotation works well to rotate the object to face the target in the pitch axis, it rotates in yaw axis to face the target.
how can i use roll + pitch instead of yaw to make the ai appear more realistic ?
additionally
i have already tried getting the angle to the target and directly adjusting mytransform.rotation, based on the angle.
ie, if angle is from 0 - 180 roll right , else roll left.
while this works for some cases, since it affects the rotation of the object which is also being used by quarternion.lookrotation it leads to not being able to steer towards the target.
thanks in advance. -poodle