what I want to happen is that when a fire hydrant is hit, it flies into the air and a water fountain appears in its place. how do I do that? The fire hydrant must remain visible as it flies into the air. I don’t really care if it lands or not, I just want it to fly into the air and then have a water fountain appear. I know I have to have a prefab for the water and I have a item for the hydrant.
how about this. the gameobject you attach this to will need a rigidbody
using UnityEngine;
using System.Collections;
public class hydrant : MonoBehaviour {
float flyTime = 2;
float currentFlyTime;
public float explosionForce = 3000000;
bool exploded = false;
void Start () {
currentFlyTime = Time.time + flyTime;
}
void Update () {
if (Time.time > flyTime && !exploded)
{
rigidbody.AddExplosionForce(explosionForce,new Vector3(0.1f,-0.5f,0),0);
exploded = true;
}
}
}
edited… AddExplosionForce is much better
(3,000,000) is a bit much for explosion, change that