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.
 
 
 
 
 

45 lines
860 B

using UnityEngine;
using System.Collections;
public class PlayerExplosion : MonoBehaviour {
public float explosionDistance;
public float explosionTime;
public int fraqAmount = 0;
// Use this for initialization
void Start () {
foreach (Transform child in transform)
{
fraqAmount++;
StartCoroutine (explosion (child));
}
}
// Update is called once per frame
void Update () {
}
IEnumerator explosion(Transform debris){
Vector3 centre = transform.position;
Vector3 scaleDirection = debris.position - centre;
Debug.Log ("Scale Direction" + scaleDirection);
for (float i = 0; i < 1; i += Time.deltaTime/explosionTime) {
debris.position =centre +( scaleDirection * Mathf.Lerp (1, explosionDistance, i));
yield return null;
}
fraqAmount--;
if (fraqAmount == 0) {
Destroy(gameObject,0.0f);
}
}
}