Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

How to create a time bomb in Unity?

$
0
0
I am making a small arcade game, and I am trying to randomly instantiate a bomb that will explode after a while. But, when it explodes, it doesn't add the explosion force. Here is the code: using UnityEngine; using System.Collections; public class Bomb : MonoBehaviour { public ParticleSystem BombBlast; private float timer; // Use this for initialization void Start () { timer = Random.Range(5,10); } // Update is called once per frame void Update () { if(timer > 0) timer -= Time.deltaTime; else { Vector3 position = this.transform.position; ParticleSystem bombexplosion = (ParticleSystem)Instantiate(BombBlast,position,Quaternion.Euler(100,0,0)); bombexplosion.Play(); rigidbody.AddExplosionForce(10000.0f,position,5000.0f); Destroy(this.gameObject); } } } No explosion force is being added. Also, I want to make the bomb solid in the sense that objects should not be able to pass through it. All objects except my player are stopped by it, but my player just goes straight through. How can I stop that?

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>