I seem to be having a few issues with getting “rigidbody.AddExplosionForce” to work.
I am making a basic Pinball game and I have the following script attached to the ball:
using UnityEngine;
using System.Collections;
public class DeflectorBounce : MonoBehaviour {
public float force = 0.0f;
public float radius = 0.0f;
void OnCollisionEnter (Collision collision){
if (collision.gameObject.tag == "Deflector"){
rigidbody.AddExplosionForce (force, transform.position, radius);
Debug.Log ("Bounce");
}
}
}
What this is supposed to do is detect a collision with a deflector, then add an explosion force to propel the ball.
I have tried everything I can think of, but I still cannot get the explosion force to work. I have even used the example in the scripting reference… that didn’t work either.
Even code that works perfectly in another project does not work here.
If anyone has any suggestions they would be greatly appreciated.
The 4th parameter is optional, and I am not getting any errors in the console.
What is confusing me the most is that even the code in the documentation isn’t doing anything either.
And this isn’t the first time I have used the function. I have used it in several other projects and it worked fine.
some ideas: did you try excessive high values for force? is the radius large enough? what are the values if you log the rigidbodies velocity in fixedupdate? is your rigidbody set to kinematic? is the rigidbodies velocity somehow modified in the same frame? is something unusual in your physics settings?