I have a vertical missile with launcher that should find closest target and fire it's rocket to hitting target!
I use complete code of this 12min tutorial for launching my rocket, and the different between mine and its about the direction of rocket, mine is vertical and its horizontal!
homingMissile.velocity = transform.forward * missileVelocity;
Quaternion targetRotation = Quaternion.LookRotation(target.position - transform.position);
homingMissile.MoveRotation(Quaternion.RotateTowards(transform.rotation, targetRotation, turn));
After running the code, the rotation of my rocket change from (0,0,0) to (-8 .3,-4.7,0)!!!! and just change a little while hit target and explosion do.
In fact my rocket move to target in right path, but in wrong rotation!, in STRANGE!
Anyone can help me for this problem?
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, turn);
instead of thishomingMissile.MoveRotation(Quaternion.RotateTowards(transform.rotation, targetRotation, turn));
furthermore I would like to know the value ofturn
, it must be between 0 to 1. \$\endgroup\$