- Home /
Having A Missile Follow An Enemy (Heat Seeker/Homing)
So, I was wondering how I would go about making some kind of 'heat seeking' missile that follows a target.
Thing is though, I can imagine the missile just following the target directly (rather than the missile adjusting its rotation to face the target) ... if that makes any sense?
Well lets just take it one step at a time, if you can help me, that would be great.
-- Edit --
I found this:
var targetTag : String;
var target : Transform;
var speed : float = 5;
function Start () {
var tar = GameObject.FindWithTag(targetTag);
if(tar)
target = tar;
}
function Update () {
transform.lookAt(target);
transform.Translate(Vector3.forward*speed*Time.deltaTime);
}
But I get error saying: Cannot convert GameObject into Transform??
Answer by Kourosh · Nov 28, 2010 at 05:50 PM
About the error: you are assigning a gameobject(tar) to a transform (target). it should be:
target = tar.transform;
Answer by kiran · Nov 28, 2010 at 04:56 PM
first we have to keep record of target trail positions ,say 20 ,and using those positions create way-points with keeping minimum traveling cost fallow the target avoid unnecessary traveling .that's it simple,but coding is hard tough
Do you have any references in where I could get some code from? Or tutorials?