I copy and pasted the unity API on Rigidbody.AddExplosionForce
and it didn’t work, is their anything i have to do to my scene to prep it?
using UnityEngine;
using System.Collections;
// Applies an explosion force to all nearby rigidbodies
public class TestExplosion : MonoBehaviour {
public float radius = 5.0F;
public float power = 10.0F;
void Start() {
Debug.Log ("bang");
Vector3 explosionPos = transform.position;
Collider[] colliders = Physics.OverlapSphere(explosionPos, radius);
foreach (Collider hit in colliders) {
Rigidbody rb = hit.GetComponent<Rigidbody>();
if (rb != null)
rb.AddExplosionForce(power, explosionPos, radius, 3.0F);
}
}
}
Did you already try LaneFox’s suggestions posted here 4 years ago? Because an explosive force of 3 is probably going to result in a similar force to a firecracker going off under a bus.
I have a similar problem, I am trying to launch my player, but it doesn’t get knocked back at all, he has a Rigidbody, capsule collider, and player controller, the knock back number is 1500. it is not kinemetric either