I just want to disable a script that's in my player-manager. But because my enemies spawn through Set Active the public game object just isn't working. Ive tried making my player-manager also a prefab but there's no solution. Can I just manually specify it through a specific GameObject in the script through line of code?
As minor as this seems I did do research and most point towards specifically using public GameObject. Unless I'm not searching well enough very new to C#.
public float lookRadius = 40f;
//public Casting stop;
Transform target;
UnityEngine.AI.NavMeshAgent agent;
Rigidbody theRigidBody;
void Start(){
    target = PlayerManager.instance.player.transform;
    agent = GetComponent<UnityEngine.AI.NavMeshAgent>();
}
void Update(){
    float distance = Vector3.Distance (target.position, transform.position);
    if (distance <= lookRadius)
    {
        agent.SetDestination (target.position);
        if (distance <= agent.stoppingDistance)
        {
            FaceTarget ();
        }
        if (distance < 10f) // or some distance
        {
            //gameObject.GetComponent<Casting>().enabled = false;
            Debug.Log("nearby heyy");
        }
    }
}
void FaceTarget()
{
    Vector3 direction = (target.position - transform.position).normalized;
    Quaternion lookRotation = Quaternion.LookRotation (new Vector3 (direction.x, 0, direction.z));
    transform.rotation = Quaternion.Slerp (transform.rotation, lookRotation, Time.deltaTime * 5f);
}
// Use this for initialization
public void OnObjectSpawn () {
    //myRender = GetComponent<Renderer> ();
    theRigidBody = GetComponent<Rigidbody>();
}
void OnDrawGizmosSelected()
{
    Gizmos.color = Color.red;
    Gizmos.DrawWireSphere (transform.position, lookRadius);
}
}
 
    