Let’s assume; There are 5 enemies. How can I stop other enemies for 2 seconds if I kill one? I don’t wanna stop player so i can’t use “Time.timeScale = 0” . I mean I don’t know how to use it.
My enemy script;
public class Enemy : MonoBehaviour
{
public GameObject player;
public float movementSpeed = 4;
void Start()
{
player = GameObject.FindWithTag("Player");
}
void Update()
{
transform.LookAt(player.transform);
transform.position += transform.forward * movementSpeed * Time.deltaTime;
}
void OnCollisionEnter (Collision col)
{
if (col.gameObject.tag.Equals ("Bullet"))
{
Destroy (col.gameObject);
Destroy(transform.parent.gameObject);
Destroy (this.gameObject);
}
}
}
What do you mean by stop them? Do you want the animations to freeze, or just stop attacking the player? In any case, you’ll need the enemies to have a script that can be told when they should pause, and then have them tell all the other enemies to pause when they die. FindObjectOfType() could be useful for that.
The enemies are just walking towards the player. No attacks. When I kill one, I want the others to stay in place for two seconds. Then I want them to walk back to the player.