Welcome, Guest

Topic: Locked On Missile

Posts: 3 Likes: 0


I am using 5.5.3 and I am trying to write a code for a homing missile, and I am using transform.lookat(), and moving it in Z Direction, is there any better way of doing it?

Posted : 2 months 4 weeks ago top

Posts: 4 Likes: 0


Hi Kshitij,
Homing missiles will generally lock on to a target and keep following it OR the missile might auto-destroy after a certain period of time without hitting target.procedure is as follows :

--> We can controlled speed of the projectile in Update() function using speed variable :
transform.Translate(0,0,speed * Time.deltaTime,Space.Self);

--> Self-destructs after a set amount of time :
Void Start ()

void SelfExplode() {
yield return new WaitForSeconds(autoDestroyAfter);
void Explode()

--> The Homing missiles needs to follow the target :

Vector3 relativePos = target.position - transform.position;
Quaternion rotation = Quaternion.LookRotation(relativePos);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, homingSensitivity);

Hope this will help you.

Posted : 2 months 4 weeks ago top

2 Item(s)

per page
Copyright 2017, GameGorillaz.
Game Gorillaz name and logo is registered trademark of Miracle Studios Pvt Ltd.