Homing Missile Part 2

How to rotate the missile towards the target

Tristan Engel
Jun 30, 2021

Script Rotate Missile to look at the Target

To achieve this we use the following function to calculate the angle.

We add the following code in our HomingMissile script in the Update() method.

float angle = Mathf.Atan2(_direction.y, _direction.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);

--

--

Tristan Engel
Tristan Engel

Written by Tristan Engel

Aspiring developer that’s self-learning Unity & C# to transition to a career with Unity. I got a passion for creating interactive experiences.

No responses yet