Disabling / reenabling OnCollision callbacks?

Hi,

I’m building a fairly complex physics LODing system for a game prototype, with the target platform being iPhone.

I’m using OnCollisionStay to effectively count collisions (I can’t use Enter / Exit only, as I’m swapping out differnt rigid bodies due to the LODing, and this interferes with the consistency of using Enter/Exit only)

What I’ve found, is having the Stay callback active (even though it’s doing almost nothing) reduces my performance massively.

I actually only need the collision count for 1 block at a time, so ideally I’d like to leave the callbacks disabled for all the other objects, and enable them for the object I’m interested in.
Is this possible?

I tried adding a seperate script, and only enabling this script for the object I’m interested in, but it appears collision callbacks within a script are called even if the script itself is not enabled.

Is my only option to create a different GameObject and toggle this in / out as I need the callbacks enabled / disabled?

Cheers,

Elton

The solutions that seems to work OK for this, is to simply keep the collision handling in a seperate script, and add and destroy this component object as required, rather than use enabled true/false.

I’ve got a feeling that having multiple scripts attached to gameobjects is a bit of a drain on performace anyway, so I’m thinking of moving the custom data I need to add per object, so it’s not a class in a script attached to a gameobjetc, but stored along side a reference of the object in some custom object management code. Will require a little search if I need to get back to this data from a reference to the object or a sub-component, but I think that’s going to be rare.