so i want to create a script for a homing missile when the target rotate the missile also rotate but in realistic way i dont want it to reverse it rotation and follow the target i want more like this way on the picture
this the code that i used i tought if used slerp it well do the job but the missile behave like what i said above
public class EnemyMovment : MonoBehaviour {
public GameObject plane;
public float speed = 15f;
public float turningSpeed = 5f;
void Start () {
}
// Update is called once per frame
void Update () {
destroyPlane();
}
void destroyPlane()
{
Vector3 Target = plane.transform.position;
Vector3 distance = Target - transform.position;
var angle = Mathf.Atan2(distance.y, distance.x) * Mathf.Rad2Deg - 90;
transform.rotation = Quaternion.Slerp(transform.rotation,(Quaternion.AngleAxis(angle, Vector3.forward)),turningSpeed*Time.deltaTime);
transform.position = Vector3.MoveTowards(transform.position, Target, speed * Time.deltaTime);
}
}