Tracking Projectiles?

I am looking for a method that will allow the NPC to perceive incoming missiles.

If I send a message of either the transform or gameObject to the NPC and it is either destroyed by the time limit or impact, does the variable becomes null automatically or do I need to check if object still exists?

Thanks CSDG

There are several ways to achieve the behaviour that you want to implement. Listed below are some ways of doing this:

  1. Parent a number of trigger colliders around your NPC and invoke your NPC’s dodging behaviour when any of the colliders is triggered by an incoming missile.
  2. Call Physics.OverlapSphere in your NPC’s Update method with the center set to your NPC’s transform.position.
  3. Have the missile continuously pass its transform.position to the NPC and have your NPC implement its dodging mechanism when the distance between the missile’s transform.position and the NPC’s transform.position is within a specified range.

#2 is the most sensible way to achieve your desired effect, in my opinion.