Most efficient way to handle projectile collisions?

In regards to bullets, missiles, etc. what is the most performance efficient way to handle their collisions and events?

Is it best to store evens on each object prefab that is effected by projectiles, check the tag of the projectile, and then initiate the event?

Or is it best to store the events on the projectile itself and send them to whatever object it’s colliding with?

For the most general use of projectiles in a game, stick your code on to your projectile as it would be the object that can initiate a change on whatever it is interacting with.

You would for this apply a collider to the object, set it to “isTrigger” and add a rigidbody (here you may choose to make it “isKinematic” or just uncheck the “useGravity” checkbox and contstrain all posiitons and rotations in the later options for the rigidbody component)

Your receiving object should also have a collider attached, though it is not necessary to set to “isTrigger” on that one.

This then sets up a style for coding triggered collisions.

    void OnTriggerEnter(Collider col)
    {
    //all projectile colliding game objects should be tagged "Enemy" or whatever in inspector but that tag must be reflected in the below if conditional
    if(col.gameObject.tag == "Enemy")
    {
      Destroy(col.gameObject);
//add an explosion or something
//destroy the projectile that just caused the trigger collision
Destroy(gameObject);
    }

I have given you a trigger solution due to Triggers being a little more efficient at runtime over OnCollisionEnter() or raycasting(Physics.RayCast)-both options that may otherwise suit you, but are more expensive to use overall).
This isnt a quote from Will Goldstone, but it sure stayed in my head form his Unity3X Game Development Essentials book, an excellent early resource.

Cheers bud and hope that helped in some way.
take care
Gruffy

How do you do an explosion?