Strange problem with rotation missile | unity3d - c#

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!

Standby Rocket

Moving to Target

Anyone can help me for this problem?

• You could try using this transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, turn); instead of this homingMissile.MoveRotation(Quaternion.RotateTowards(transform.rotation, targetRotation, turn)); furthermore I would like to know the value of turn, it must be between 0 to 1. Commented Jun 24, 2019 at 8:21
• hey @DigvijaysinhGohil, it's not work again. just rotation from (-8.5,-4.5,0) changed to (-10,-27,0)! The value of turn was 20 in first, but now i change it to 0.5 but not solving my problem. Commented Jun 24, 2019 at 8:43
• Is z axis or blue arrow of rocket points to the tip of the rocket in local space? Commented Jun 24, 2019 at 9:54
• @DigvijaysinhGohil nope, it's y axis Commented Jun 24, 2019 at 9:58
• That is the reason it is not rotating correctly, just create empty gameobject and assign the script to it, then make rocket as the child of empty object and rotate it in a way that the tip points to the z axis of empty object, also swap the collider and rigidbody to the empty gameobject as well Commented Jun 24, 2019 at 10:09