first grade.

public class Triggerforenemy : MonoBehaviour { public bool Trigger = false; private void OnTriggerStay(Collider other) { if (other.tag == "Player") { Trigger = true; } } 

}

second class` {// script for

 // Цель к которой будем двигаться public Transform target; public Triggerforenemy hello; // Скорость персонажа в секунду public float speed; void Update() { if (hello.Trigger == true) { // Размер шага равен скорость * время кадра. float step = speed * Time.deltaTime; // Переместите нашу позицию на шаг ближе к цели. transform.position = Vector3.MoveTowards(transform.position, target.position, step); } } 

} `

In principle, the object capsule should move to the object character but the capsule for some reason does not move towards it

    1 answer 1

    All thanks, I figured it out myself. Target is the goal to which the object should go. And I thought it was the object itself, which is following.