Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Vink on December 04, 2012, 05:55:02 AM

Title: Particle Collision
Post by: Vink on December 04, 2012, 05:55:02 AM
Hello every

Im wandering if there is a way to use playmaker to detect particle collision?
i just made a pretty cool particle system where it looks like the thing is shooting spikes, i managed to make playmaker turn the "emit" on and off with left click and it automatically detects collision when it hits other colliders and destroys the particles, i had a look at "get collision info" and tried using that to store the game object it hits, but i couldnt figure it out

im using an empty game object with these components: Ellipsoid particle emitter, particle animator, particle renderer  and world particle collider
Title: Re: Particle Collision
Post by: Alex Chouls on December 07, 2012, 01:41:20 AM
This would take a little work to hook up in Playmaker.

The general Unity approach is described here:
http://answers.unity3d.com/questions/10717/detecting-particle-collisions.html

However, PlayMakerFSMs don't currently respond to the OnParticleCollision event. You could make a small proxy script that forwards the event to a PlayMakerFSM on the same object... I'll try to find some time to code that, or perhaps someone else will jump in :)

I'll look into getting this event into a Playmaker update... it would be cool :)
Title: Re: Particle Collision
Post by: Rabagast on January 06, 2016, 12:22:23 PM
Hi!
Is it any update on this? I'm trying to do the same.
Title: Re: Particle Collision
Post by: Kubold on February 22, 2016, 02:13:55 PM
Four years later and noone did this little proxy script ever?...
Title: Re: Particle Collision
Post by: mdotstrange on February 22, 2016, 11:30:46 PM
I threw one together really quickly just now- its attached or here https://snipt.net/mdotstrange/particlecollisionpm/ (https://snipt.net/mdotstrange/particlecollisionpm/)

To use it add it to your particle system object- make sure the particle system has Collisions on- set the collisions to world and also check Send Collision Messages

The script will send an event called "Hit" to an Fsm on the Particle System object- it also sends the hit position as a Vector3 you can grab with "Get event info"

Add script and an fsm to the game object with Particle System
(http://i.imgur.com/99p3xOP.png)

Particle system collision setup
(http://i.imgur.com/NTkNgAT.png)

"Hit" event sends hit position vector3
(http://i.imgur.com/0tVcnGH.png)
Title: Re: Particle Collision
Post by: Rabagast on February 23, 2016, 12:59:08 AM
Hi, mdotstrange!

Thank you for this! Just a question.

In the Collision on the Particle System, I don't have Collision Mode and some other options there like you have in the screenshot here.

Title: Re: Particle Collision
Post by: mdotstrange on February 23, 2016, 01:11:09 AM
What version of Unity are you using? I'm on 5.3 so maybe those options are from a newer version?
Title: Re: Particle Collision
Post by: Rabagast on February 23, 2016, 02:26:58 AM
I have 5.2, so it's probably in the newer version. But it works anyway. :)
I tried to create a particle which will damage the player, but it didn't work. Does it only works witch particles which are already in the scene?
Title: Re: Particle Collision
Post by: mdotstrange on February 23, 2016, 08:28:18 AM
I don't understand what you are asking- You have to apply the script to any particle system you have in the scene- and it will send hit events for the hits that system collides with- you can do whatever you want with the hit data- use it to damage enemies or whatever you'd like-
Title: Re: Particle Collision
Post by: Rabagast on February 23, 2016, 12:56:03 PM
Forget it! It works fine! :)
Again, thank you for this! :)
Title: Re: Particle Collision
Post by: Kubold on March 09, 2016, 02:40:42 PM
Awesome :)
Title: Re: Particle Collision
Post by: christougher on August 17, 2016, 04:40:29 AM
Such a useful Script, Thx!  Wish I'd seen it earlier.
Title: Re: Particle Collision
Post by: mdotstrange on January 03, 2017, 03:45:01 PM
Attached the script since snipt is no longer.
Title: Re: Particle Collision
Post by: Rabagast on January 10, 2017, 10:03:17 AM
It's very useful script, but to be honest, I don't think we need it anymore, since Playmaker has "On Particle Collision" now. It works very well. :)
Title: Re: Particle Collision
Post by: Twood on March 25, 2017, 11:05:26 PM
It's very useful script, but to be honest, I don't think we need it anymore, since Playmaker has "On Particle Collision" now. It works very well. :)


Care to elaborate on how to use this? I can't seem to grab the normal or hit point of the particle against an object with just PM. I must be missing something.
Title: Re: Particle Collision
Post by: Rabagast on March 26, 2017, 06:48:38 AM
It's very useful script, but to be honest, I don't think we need it anymore, since Playmaker has "On Particle Collision" now. It works very well. :)


Care to elaborate on how to use this? I can't seem to grab the normal or hit point of the particle against an object with just PM. I must be missing something.


Hi!
On the particle you want to collide with, did you enable "Send Collision Message" on the Collision? You also need to change the Collision Mode depend if you use 2D or 3D Collider. If you set up the collision FSM on the particle you want to collide with, you need Rigid Body on the particle.

The last thing, on the Collision Event, you need to choose "On Particle Collision." Maybe you already did this.

Tell me if it works or not. :)
Title: Re: Particle Collision
Post by: Twood on March 26, 2017, 11:39:25 AM
It's very useful script, but to be honest, I don't think we need it anymore, since Playmaker has "On Particle Collision" now. It works very well. :)


Care to elaborate on how to use this? I can't seem to grab the normal or hit point of the particle against an object with just PM. I must be missing something.


Hi!
On the particle you want to collide with, did you enable "Send Collision Message" on the Collision? You also need to change the Collision Mode depend if you use 2D or 3D Collider. If you set up the collision FSM on the particle you want to collide with, you need Rigid Body on the particle.

The last thing, on the Collision Event, you need to choose "On Particle Collision." Maybe you already did this.

Tell me if it works or not. :)

hi, well this much works but what action do I use to gather more data? The collision event only has the hit object and force, but I want the location point the particle is hitting... but everything I try after collision event isn't giving me any additional values so what would you use? Get collision info returns zeros, physics is working and the event is triggering though.
Title: Re: Particle Collision
Post by: Rabagast on March 26, 2017, 01:19:20 PM
Quote
hi, well this much works but what action do I use to gather more data? The collision event only has the hit object and force, but I want the location point the particle is hitting... but everything I try after collision event isn't giving me any additional values so what would you use? Get collision info returns zeros, physics is working and the event is triggering though.

Hi!
I'm not really sure how to do it, if it's possible. I tried to "Get Collision Info" when I collide with particles and store everything in variables. The only thing which was stored, was the player.

I tried to do the same with a normal Game Object, then it stored everything.
Maybe Jean Fabre can explain if it's possible. :)
Title: Re: Particle Collision
Post by: Twood on March 26, 2017, 01:50:52 PM
yes, I don't think all the data is passed through PM even though they added that new collision event stuff in PM. So forget that...

good news is mdotstrange's script works AWESOME and does what I need! Thank you mdotstrange.
Title: Re: Particle Collision
Post by: Rabagast on March 26, 2017, 03:39:24 PM
Have you tried to use Get Event Info?
Title: Re: Particle Collision
Post by: Twood on March 26, 2017, 05:31:17 PM
Have you tried to use Get Event Info?

Yes, when I was trying that method. Only thing it would ever get is only what the game object was for collisions unless I missed something there. (It's quite annoying to experiment with to be honest as you start scouring the dozens and dozens of particle settings, rigidbody settings, etc looking for a problem, etc) so I'll stick with the script version. It's working fine!
Title: Re: Particle Collision
Post by: serenefox on April 12, 2018, 01:37:08 AM
I can't get this script to work. I am also trying to do this in 2d if that makes a difference(which it probably does). Also in visual studio when I took a look at the script it said a line was deprecated, but I'm not sure how to update it. Anyone available to take a look? I am ultimately trying to get the point of contact from the particle collisions to spawn something there.
Title: Re: Particle Collision
Post by: Fat Pug Studio on April 12, 2018, 02:51:20 AM
What is deprecated, we'll just take a look at documentation and update it.
Title: Re: Particle Collision
Post by: serenefox on April 12, 2018, 03:11:44 AM
I did look at it but it says to change it to a list and I am not very familiar with lists. I tried changing it but the things i tried didn’t work.
Title: Re: Particle Collision
Post by: serenefox on April 12, 2018, 03:26:45 AM
Figures I would post that and then I get it to compile but I still can't get it to pass the event data. I will keep working with it though.

Edit*** And then after I posted this I got it to work with the new updated code, so never mind... ;D
Title: Re: Particle Collision
Post by: DennisJensen on June 21, 2018, 04:46:04 AM
Just a note,

It only works if the hit object has a rigid body. I modified the script a bit so it works on all objects and added an FSM public variable where you put your FSM component into. If you have more than one FSM on the object this makes sense.