Page 1 of 1

Colliding with particle

Posted: Sat Sep 10, 2011 7:06 am
by tsturzl
I'm using Particles as ammunition in a game I'm creating, I'd like to check for collision with the particles in the system to see if they collide with the enemy. Can I do this? Is there a way to iterate through the system and get each particles x and y axis and size? Or is there any method of checking collision with a particle?

Re: Colliding with particle

Posted: Sat Sep 10, 2011 8:56 am
by Taehl
I don't think so. Why not make your own bullet system, where you store all the bullets to a table, then you can iterate through the table and check the collision via a simple distance check or something?

Re: Colliding with particle

Posted: Sat Sep 10, 2011 12:21 pm
by kikito
If I'm not mistaken, particle systems are meant to be used as visual effects only. You can't collide or interact with them in any way. You can only create them, update them, and that's it.

Re: Colliding with particle

Posted: Sat Sep 10, 2011 4:34 pm
by tsturzl
Its not shooting bullets, its shooting plasma, kinda like a flame thrower.

I guess I'll just make a body in the physics world that underlays the particle stream and test for collisions on that body.

Re: Colliding with particle

Posted: Sun Sep 11, 2011 1:53 am
by Lexsym
I'm new to love, but just thought I'd throw my two cents in: Couldn't you just create an invisible body and parent it to the particle (or just set the location of the body to that of the particle)?

Re: Colliding with particle

Posted: Sun Sep 11, 2011 9:58 am
by nevon
Lexsym wrote:I'm new to love, but just thought I'd throw my two cents in: Couldn't you just create an invisible body and parent it to the particle (or just set the location of the body to that of the particle)?
The problem is that you can't get the position of a particle.

Re: Colliding with particle

Posted: Sun Sep 11, 2011 11:21 am
by Taehl
tsturzl wrote:Its not shooting bullets, its shooting plasma, kinda like a flame thrower.

I guess I'll just make a body in the physics world that underlays the particle stream and test for collisions on that body.
Why even bother with physics? Does your plasma push things around instead of just hurting them?

But it doesn't matter if it's plasma or bullets. You have a number of small, independently-moving and colliding circles. The only difference is the graphic you put on them (and maybe they move more slowly or something).

Re: Colliding with particle

Posted: Sat Sep 17, 2011 3:12 am
by tsturzl
The particle stream pushes the enemy, it doesn't injure them.

Re: Colliding with particle

Posted: Sat Sep 17, 2011 3:41 am
by slime
You'll have to create your own particle system if you want collision detection/physics, the built-in love ones don't support that kind of stuff besides gravity.

On the other hand, often visuals in games don't match up one-to-one with what's actually going on, and most people won't notice. You could make a custom thing to push things away, and then put the particle system on top of that.

Re: Colliding with particle

Posted: Tue Sep 20, 2011 2:11 pm
by Fourex
This sounds EXACTLY like something I made a while ago. Feel free to use it as inspiration. You should remake it from scratch though, so you know the code and can edit it as you like.

EDIT: Just to be clear "use it as inspiration" means open it up and look at the code :nyu: