- Home /
How to access particle collision locations
Hi!
I am trying to make a particle based machine gun!
so far everything I have needed has come from the scripting reference, but I have been having trouble figuring out how I can tell a script where a particle collision was in a variable. This is so hit sparks can be made at a collision point.
I think what might work is telling the script that when a particle has collided, to instantiate the sparks at it's location, rather than at the collision point, which apparently the OnParticleCollision function doesn't do.
Thank you!
AJ - indie game maker and dreamer... lol :)
Answer by GODLIKE · Jun 01, 2010 at 07:23 AM
If I would be in you I'd just use a raycast to see where the gun is aiming and just relocate a particle emitter of sparks in that location (at the crossing of the ray with the first mesh). No need to spawn it: just spawn it when the player hits FIRE, then relocate it to raycast landing point until FIRE is pressed.
Hope this is a good solution for you :)
That would always work, but I just want to see if it was possible, in case I needed particles for something similar to above
Thanks!
Aj
Answer by Jesper Mortensen · Mar 07, 2013 at 03:00 PM
We are actively working on collision messaging ATM and with any luck it should go into Unity 4.2. This will let you read collision impact points, incident velocity etc. With this data you can easily cause damage and/or apply forces to collidees.