3D Heat Seeking Missile (C#) - Odd problem

setup : decoy and missile prefabs instantiated at run-time
example : Missile being launched from right side of the screen, decoy from the left.
Decoy’s trajectory is random, either upward or downward, parabolic
goal : missile should follow decoy, almost managed when chasing upwards, failed opposite.
When decoy goes down, missile starts rotating up, after reaching vertical position continues to rotate down facing slowly decoy

//direction = decoy.transform.position - missile.transform.position;
//Quaternion rotation = Quaternion.LookRotation(direction);
//missile.transform.rotation = Quaternion.Lerp(missile].transform.rotation, rotation,  Time.deltaTime * 20);
    			
missile.transform.position = Vector3.MoveTowards(missile.transform.position, decoy.transform.position, speed[2] * Time.deltaTime);
missile.transform.rotation = Quaternion.RotateTowards(missile.transform.rotation, decoy.transform.rotation, 30 * Time.deltaTime);

Searched forum, youtube, all kinds of examples, tried Lerp, Slerp, whatnot…

Here is code for decoy :

lX = 0.05f;
lY = Random.Range(-1f, 1f);
if (lY > 0)
	{
            	lY = Random.Range(0.02f, 0.04f);
            	lZ = Random.Range(0.025f, 0.05f);
        	}
        else
        	{
            	lY = Random.Range(-0.04f, -0.02f);
            	lZ = Random.Range(-0.05f, -0.025f);
	}
//previous values set once on instantiation	
decoy.transform.position += new Vector3(lX,lY,lZ);

Any thoughts will be appreciated :slight_smile:

Cheers, Miša

Almost feeling sorry I found solution after 2 weeks of trial and error :slight_smile:
In case someone else stumble upon simmilar annoyance…

//direction = decoy.transform.position - missile.transform.position;
missile.transform.position=
Vector3.MoveTowards(missile.transform.position, decoy.transform.position, speed[2] * Time.deltaTime);
missile.transform.rotation = Quaternion.LookRotation(Vector3.forward, direction);

key is the last command that seems to have no problems with orientation of a rotation…hooraaay.