rotation problem (me lio con rotacion)
Hi! I try to rotate a enemy, he must look at player and walk to him when he pass through a collider (trigger). the game is a isometric rpg, the enemy must rotate in the Y axis.
I have actualy this in Enemy script:
void Update()
{
EP = transform.position - target.transform.position; //targes is a player gameObject
//transform.LookAt (target.transform); this doestn work :/
transform.Translate (EP.normalized * vel * Time.deltaTime);
}
please forgive my poor english, and i help me! :)
thanks!!
Comment
Answer by 5c4r3cr0w · Apr 09, 2016 at 05:06 AM
You need to use MoveTowards function in order to make enemy go to target.
Try this :
void Update () {
transform.LookAt (target.transform);
transform.position = Vector3.MoveTowards(transform.position, target.transform.position, vel * Time.deltaTime);
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612074452im_/https://answers.unity.com/themes/thub/images/avi.jpg)