When player enters area. Object that script is attached to walks toward the entering object(player).

hello, thank you for anyone that can help. I want it so When player enters area. The object that the script is attached to walks toward the player. Here’s what I’m thinking:

    void OnTriggerEnter (Collider other){
    if(other.name == "Player" || other.tag == "Player"){
    /*This is where I want to put the script for having the object move to the player. Although, I don't know the function. Any help is appreciated.*/
    Debug.Log("Player Has Entered");
    }

Thanks for the help. I just forgot the function, I thought I saw one at some point, just cant think of it. It’s been bothering me for days :slight_smile: .

If it’s enemy. it’s easy. Try this.

 public GameObject Player;
 
 void OnTriggerEnter (Collider other){
 if(other.name == "Player" || other.tag == "Player"){

//Object will look to the player.
transform.LookAt(Player);

//the object will move towards the player.
transform.Translate(speed*Vector3.forward*Time.deltaTime);

 Debug.Log("Player Has Entered");
 }