Game Development Community

How do I make particles collide with other objects in game?

by Storm Kiernan · in Torque Game Builder · 05/11/2011 (5:21 pm) · 5 replies

How do I make particles collide with other objects in game? I have particles that get sent out and I need them to collide.

#1
05/28/2011 (8:07 am)
I think that it is not easy to archive this. There are several tutorials for this case but all not working.
#2
05/31/2011 (1:29 am)
There's a way, because I actually achieved it myself.
Here are the steps.

In the editor make sure you give your particle a name in the first namespace field(particle), and then give it a name for the class(particleTest). Make sure you do this or it won't work. Then make sure you check receive, send collisions and callback box.

With the sceneobject you want to collide with particle.
Set it up like so:(Example)

function myObject::onCollision( %srcObj, %dstObj, %srcRef, %dstRef, %time, %normal, %contactCount, %contacts, %this )
{


if (%dstObj.class $= "particleTest") {
particle.safeDelete();
}
}
Also make sure you set send, receive collisions, and callback box for sceneobject as well.

Now test out your level.

If this works for you let me know.
#3
05/31/2011 (12:09 pm)
Thanks for the reply but perhaps there is some missunderstanding here. I thought that he wants to let each particle collide with a scene object.

What your code does is, that when you collide with the 'particle generator box' it deletes it. So it won't delete only one particle but the hole package. Am I wrong?
#4
05/31/2011 (2:45 pm)
I do believe that Julian is correct. In any case, I've found that manually shooting out the sprites is effective and visually decent.
#5
06/01/2011 (1:51 am)
Just to make this clear. I just wanted show that you can have an object collide with particles. You can actually make any event you want to take place besides making the particle dissappear.

@ Julian

Thats not true because each particle could have its own unique name.
It would only delete one specific particle according to its name.

Sorry if I didn't make it clear.

@Storm
Good Luck with using sprites.
I've used that method as well.