I have setup code for enemy prefab clones to follow player till they touch him then stop following, problem is the follow player boolean only changes on the prefab but not the clones
(the code is attached to the player)
using UnityEngine;
public class PlayerCollision : MonoBehaviour {
public Movement movement;
public GameObject player;
public float Threshold = -5;
public GameObject enemy;
private void OnCollisionEnter(Collision collisionInfo)
{
if (collisionInfo.collider.tag == "Enemy")
{
//Stop following player
enemy.GetComponent<Enemy>().followPlayer = false;
//disable movement
movement.enabled = false;
//remove ammo
player.GetComponent<Shooting>().maxAmmo = 0;
player.GetComponent<Shooting>().currentAmmo = 0;
}
}
}