Game Development Community

Collisions For Comet Tail, Possible?

by Leo Gura · in Torque Game Builder · 11/17/2006 (1:08 pm) · 5 replies

I've got a moving objec to which Iive mounted a particle emitter to create a comet tail effect. Now I've got other object colliding with the comet tail and what I need is for that object (or any object that collides with the tail) to be destroyed. Is this possible in TGB? What callback tells me that one of my objects has hit a particle?

#1
11/17/2006 (1:15 pm)
You use
onParticleCollision
.
You have to check "Use Effect Collisions" on the effect too.

Edit: If it wasn't clear, you use that callback on the particle effect itself.
#2
11/17/2006 (3:09 pm)
Okay, but the "onParticleCollision" callback does what? It will sound whenever the particle collides with anything, as I understand. How do I limit it to just a particular type of object, and how do I get the ID of the instance the particle collides with so I can destory it? This isn't possible with the above mentioned callback, is it? Is there a callback that I can use in the object as opposed to the particle effect itself? That would solve my problem.
#3
11/17/2006 (3:17 pm)
Hmmm. Good point. Particle collision isn't very well supported as far as I can tell. It seems more like it's intended to enable particles to get blocked by things than to have them be used for callbacks.

I'd recommend either making an invisible shape that roughly mimics the comet's tail or make some of your own objects that are emitted along the tail but actually do have collision on them. It's probably not necessary to have every particle checked for collision unless the tail is really long and has a really low density.

Hopefully that helps ;)
#4
11/21/2006 (7:39 pm)
I was hoping to avoid generating a trail of real, invisible objects behind my comet tail but I've implemented it and it works quite well. My comet tail if very long and I have many of them so I'm a bit concerned about performance. In an effort to reduce CPU usage I created an alternative method. My player object--- the one generating the comet tail--- has a 10 slot 2D array which is updated every 150 milliseconds, recording the latest player coordinates. This way I get a table with 10 snapshots of where the player was and can us "pickLine()" to check for collisions between every point. I've implemented both methods and tested them out for efficiency but can't discern any notable difference in FPS. I was quite surprised because I was sure that creating and destroying objects every 100 milliseconds would be less efficient that using the array and pickLine method, but I guess not so much. One drawback I've found to the pickLine method is that I can't produce intelligent-like enemy AI to avoid the comet tail (which is lethal) because there are no objects against which to check for collisions, and I can't use collision cast either. Since AI is probably going to make the game more fun, I guess I'll be going back to the object creation method.
#5
11/22/2006 (10:45 am)
If you uncheck "Use Effect Collision" on the particle effect in the Level Builder it will then pass all of the collision info down to each particle. Two things to note:

1) It only uses the center of the particle for collision for efficiency.

2) Setting the collision layers and groups in the Level Builder on the Particle Effect is currently broken, so simply set it in script, such as:

testP.setCollisionGroups(0);
testP.setCollisionLayers(0);

You can set this via a class if you would like...

The particles do take the response from the effect as well, such as KILL, CLAMP, BOUNCE, etc.