Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class ExploderBg : MonoBehaviour {
- public GameObject ExplosionPrefab;
- public int HitCount = 1;
- private int HitTracker = 1;
- public float ImpactThreshold = 15.0f;
- public float LifeSpan = 10.0f;
- void OnCollisionEnter (Collision collision) {
- if (collision.relativeVelocity.magnitude > ImpactThreshold){
- HitTracker += 1;
- }
- }
- void FixedUpdate(){
- if (HitTracker > HitCount) {
- var bullet = (GameObject)Instantiate (
- ExplosionPrefab,
- transform.position,
- transform.rotation);
- Destroy (gameObject);
- Destroy (bullet, LifeSpan);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment