multiple object collisions

hi,

I’m having some problems with collisions and they way it triggers stuff.

basically, I want to be able to test if a collision takes place between a box collider and a mesh collider, and if so, then it will change a variable on the script on the mesh object which will do a bunch of stuff, and then destroy the mesh object.

I’ve managed to get this working, in that when an event happens, the box collider moves, it hits the mesh and a triggerevent happens which changes a variable on the mesh, and that then sets in play the events that lead to the mesh being destroyed.

my problem is, i just tried it with multiple meshes, figuring that the collision would trigger the script on all instances, but it doesnt, it triggers one at a time in the order the meshes were instantiated…

so, I’m at a loss as to how to make it call all of them at the same time.

Heres the code from my trigger collider.

function OnTriggerEnter (other : Collider) {
if(other.gameObject.tag == "Colonist"){
var script = other.gameObject.GetComponent("Colonist");
script.colonistdie=true;
}}

any suggestions? I’m probably missing something simple, but i’ve been working on this for a while now and it’s starting to fry my brain :stuck_out_tongue:

Do you mean that there is an unwanted time delay between the various calls to OnCollisionEnter, or that you need to take account of all the hit objects at once (because they have some kind of priority in the game, say)? If it’s the latter then you might be able to add the relevant objects to an array during all the OnCollisionEnter calls, and then examine them in the Update method. (See this thread for the execution order of the event functions.)