using UnityEngine;
|
|
using System.Collections;
|
|
|
|
public class fracExplosion : MonoBehaviour {
|
|
public float explosionDistance;
|
|
public float explosionTime;
|
|
public bool triggerExplos = false;
|
|
|
|
public GameObject titleScreen;
|
|
public GameObject menu;
|
|
|
|
|
|
// Use this for initialization
|
|
void Start () {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update () {
|
|
|
|
if (triggerExplos) {
|
|
triggerExplos = false;
|
|
//Debug.Log (transform.position);
|
|
foreach (Transform child in transform)
|
|
{
|
|
StartCoroutine (explosion (child));
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
IEnumerator explosion(Transform debris){
|
|
Vector3 centre = transform.position;
|
|
Vector3 scaleDirection = debris.position - centre;
|
|
|
|
for (float i = 0; i < 1; i += Time.deltaTime/explosionTime) {
|
|
debris.position = scaleDirection * Mathf.Lerp(1,explosionDistance,i);
|
|
|
|
yield return null;
|
|
}
|
|
gameObject.SetActive (false);
|
|
|
|
titleScreen.SetActive(false);
|
|
menu.SetActive (true);
|
|
|
|
|
|
}
|
|
}
|