Game Development Community

onParticleCollision?

by Kevin James · in Torque Game Builder · 06/14/2010 (12:32 pm) · 7 replies

How does this work? I did a search but everything I turned up comes from people struggling to get it to work. I have the check box checked and I add this line:
%this.setEffectCollisionStatus(true);

but alas the collision is not detected.

About the author

Computer security, digital forensics, and platform jumper enthusiast. shells.myw3b.net/~syreal/


#1
06/15/2010 (4:24 am)

setEffectCollisionStatus(status)
status: True if the effect as a whole is processing collisions, false if the individual particles are processing collisions.


So, you need to use %this.setEffectCollisionStatus(false) with the callback onParticleCollision(%this)
#2
06/15/2010 (5:54 am)
Changing this setting makes no difference.
#3
06/15/2010 (6:37 am)
How are you trying to pickup the collision callback?
#4
06/15/2010 (6:51 am)
I tried it both ways, in the particle class and then in the enemy class. Both ways fail to detect it. Do some people have this working?

function empStun::onParticleCollision( %srcObj, %dstObj, %srcRef, %dstRef, %time, %normal, %contactCount, %contacts )
{
   echo("empStun::onParticleCollision");//never gets here
}

#5
06/15/2010 (6:56 am)
Is empStun the class or name of the emitter?

Try the following, it should catch ALL particle collisions in your game:
function t2dSceneObject::onCollision( %srcObj, %dstObj, %srcRef, %dstRef, %time, %normal, %contactCount, %contacts )
{
   echo("onParticleCollision called for:" SPC %srcObj SPC "with class:" SPC %srcObj.class);
}
Once you get it trapped, you can debug the %srcObj and figure out how to catch it properly.

I've only tried this once before but it was with tileMap collisions for someone else's game so I don't have the code but I think that the problem was that the particle has a different namespace than the emitter and wasn't being caught by my callback function.

Note, this is untested and my best guess. I hope it helps.
#6
06/15/2010 (7:52 am)
I'll give this a try, thanks!
#7
06/15/2010 (10:24 am)
Kevin,

Note I edited my post to do just onCollision (as opposed to onParticleCollision). Then you filter...