- Home /
How can i make particles push back the player on collision?
Hello, I am fairly new to Unity and an amateur (I'm more of a designer than a programmer).
I am doing University work and I'm trying to make my character cause an explosion, and when the player sets off the explosion particles emitter, I want the particles to knock the player backwards (obviously this would mean getting direction of the particle and move the player accordingly rather than a set movement), how would I go about doing this? I have a method of getting the direction (I think):
function OnParticleCollision (go_Part_System : GameObject)
{
if(st_PC_State == "Alive")
{
if(go_Part_System.gameObject.tag == "Explosion")
{
var direction: Vector3 = go_Part_System.transform.position - transform.position;
direction = direction.normalized;
So how would I go about pushing the player back in the direction of particle collision?
Any assistance would be GREATLY appreciated.
I think if you put a RigidBody on the player, the particle physics can work, but you might want to look at the Detonator Pack. I recall a setting for 'explosion force' which would knock things around nicely.
Answer by squall-lionheart · Dec 22, 2012 at 03:06 AM
I tried adding a RigidBody to the character but it didn't work (unless I'm doing something wrong)
Also, I looked at the Detonator Pack but don't think it will be as useful for me to be honest ^^ But I have looked at this from it: http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.AddExplosionForce.html
will that be useful in this case? ALSO when I DID try adding a RigidBody to my character, I have a problem where it just passes through the world unless I turn Gravity off for the RigidBody (tbh I'm guessing this is why it wasn't affecting the player?)