private void OnTriggerEnter(Collider other) { // If the thing we collided with has a SonicDetectable component, and it's within innerRadius... sonicDetectable = other.gameObject.GetComponent <SonicDetectable>(); if (sonicDetectable) { sonicDetectable.OnPing(pingSource, transform.position); } }
private void Start() { sonicDetectable = (SonicDetectable)GetComponent(typeof(SonicDetectable)); agent = (NavMeshAgent)GetComponent(typeof(NavMeshAgent)); currentHealth = maxHealth; knowledgeLevel = KnowledgeLevel.Unaware; agent.speed = patrolSpeed; agent.angularSpeed = angularSpeed; keepOrbitDistanceSqr = keepOrbitDistance * keepOrbitDistance; }