Help with RigidBody.AddExplosionForce

Hello all
So I can’t seem to get this code to work. I wasn’t getting any errors, but wasn’t seeing any results either
Just trying to make the explosion from the enemies knock the others back

public class PlayerStatusController : MonoBehaviour {
	public int lives = 5;
	public int enemycount = 3;
	public ParticleEmitter EnemyExplosion;

	public void OnGUI() {
		GUI.Label(new Rect(29, 29, 100, 29), System.String.Format ("LIVES: " + lives));
	}
	
	public void OnTriggerEnter(Collider collider){
		lives -= 1;
		Vector3 EnemyPosition = collider.transform.position;
		Destroy(collider.gameObject);
		ParticleEmitter explosion = (ParticleEmitter)Instantiate (EnemyExplosion, EnemyPosition, Quaternion.identity);
		explosion.Emit();
		
	    Vector3 explosionPos = transform.position;
        Collider[] colliders = Physics.OverlapSphere(explosionPos, 5.0f);
		
		foreach (Collider hit in colliders) {
            if (!hit){
				continue;
			}
            
            if (hit.rigidbody){
                hit.rigidbody.AddExplosionForce(20.0f, explosionPos, 5.0f, 10.0F);
			}
		}
	}
}

Thanks for the help, Unity noob in training here x)

Try massively more powerful force values. Depending on distances and weights, possibly tens of thousands.

I also get an error when testing the game at the line that reads

ParticleEmitter explosion = (ParticleEmitter)Instantiate (EnemyExplosion, EnemyPosition, Quaternion.identity);

which states “InvalidCastException: Cannot cast from source type to destination type”

Got it working. I was using a tutorial that had me using ParticleEmitter when I should’ve been using (since 4.0) ParticleSystem
and massively increasing the values helped. What exactly is 1.0f equal to in relationship to the units of the xyz axis?

Thanks for helping this humble scrub :slight_smile: