Hello to everyone!
I have a script attached to an enemy prefab that makes it start moving when the player enters it’s trigger collider. My problem is that once the player enters an instance’s trigger collider, all of the other instances start moving as well instead of just the instance I want.
This is the script attached to the prefab:
void FixedUpdate() {
if (activated)
rb.velocity = (Vector3.down * 1.5f * enemySpeed);
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.CompareTag("Player") )
{
activated = true;
}
I will appreciate any help or tips.
Thank you!