You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

52 lines
956 B

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);
}
}