Problem with AddExplosiveForce
Hey all, I have a question regarding AddExplosiveForce. Below are the details of the project:
I have a car, with four wheel colliders, and a box collider for the car body. In the scene is a box mesh with a box collider. I also have a prefab made up of 9 additional box fragment meshes that make up the main box. All have a rigidbody and box collider component.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
[System.Serializable]
public class DestroyScript : MonoBehaviour
{
public float boomSize;
public float boomRad;
public GameObject remains;
void OnCollisionEnter (Collision col)
{
if (col.gameObject.name == "SM_Car_PosZ")
{
destroyObject();
}
}
void destroyObject()
{
Vector3 boomPos = remains.transform.position;
Destroy(gameObject);
Instantiate(remains, transform.position, transform.rotation);
remains.GetComponent<Rigidbody>().AddExplosionForce(boomSize, boomPos, boomRad);
}
}
I applied the above script to the main box. So when I drive my car into the main box, it is destroyed as expected and the prefab, consisting of the 9 box fragments, are instantiated in its place properly. However, they sort of just fall apart, vs being blown apart. I tried values between 0.5 to 100 for both boomSize and boomRad but there's no visible difference.
Does anyone know why the force being applied is not changing, or not explosive?
Additionally, the SM_Car_PosZ is the name of the car. The prefab I called PF_BoxFragments was input into the public remains variable.