0
\$\begingroup\$

I have a lightning particle that gets shot at the ground. I want the particles to collide with the object they hit and add an upward force. I tried just entering a negative force in the Collider Force tab but it defaults to 0. If anyone knows a way to do this it would be greatly appreciated!

Lightning Particle System

Edit: I want to send the cube in the photo upwards by adding a force on its y-axis. The Particles should remain as they are. enter image description here

\$\endgroup\$
1
\$\begingroup\$

After searching and searching it turns out I needed to toggle the Send Collision Message bool. If anyone is wondering how to get this to work, toggle on this bool in the inspector: enter image description here

and this is the code I used to get it moving:

void OnParticleCollision(GameObject other)
{
    if(other.GetComponent<Rigidbody>() != null)
    {
        other.GetComponent<Rigidbody>().AddForce(transform.up * 160);
    }
}
\$\endgroup\$
0
\$\begingroup\$

I hope that what you are trying to achieve is to make the particles bounce back from a surface. I do not think we need collider force for that. Just set bounce value to non zero. That should work.

Simple Reflection Example01

Strictly Upward Example02

If you want the particle rebound to go upward only, use the trigger section just like you would use BoxCollider2D. Use another particle system to send particle upwards.

rebound and upward

I would guess you have to write a script for particle system to fire whenever a collision is detected on the plane. The second alternative sounds cleaner. Just cover up the ground with a lot of light, nobody will notice :)

Good Luck.


enter image description here

Particle system has a list of collision events. This script checks collisions and matches tags. If tags match, then action is executed. Uncomment flag= true if you want only one collisions.

\$\endgroup\$
  • \$\begingroup\$ Hi @suvam0451 thank you very much for taking the time to respond. I guess I wasn't very clear in my question but I've edited my question so you can better understand what I'm asking. Thanks so much :) \$\endgroup\$ – JeffBrin Jan 6 at 21:12
  • \$\begingroup\$ You only want the first particle to affect the cube, right ? Because if all particles start adding velocity, the cube would fly out. \$\endgroup\$ – suvam0451 Jan 6 at 21:14
  • \$\begingroup\$ No, I want all the particles to affect it because it's meant to be an attack that launches another player up in the air. \$\endgroup\$ – JeffBrin Jan 6 at 21:32
  • \$\begingroup\$ got it working, uploading now... \$\endgroup\$ – suvam0451 Jan 6 at 21:41
  • 1
    \$\begingroup\$ No problem man. I learnt something new too :). cheers. \$\endgroup\$ – suvam0451 Jan 6 at 21:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.