using UnityEngine;
using System.Collections;
public class DeathCubeProcedure : MonoBehaviour {
public GameObject Target;
public GameObject Player;
// Use this for initialization
void Start () {
StartCoroutine ("Procedure");
}
// Update is called once per frame
IEnumerator Procedure(){
while (gameObject.activeSelf) {
for(int i=0; i>4;i++){
Instantiate(Target,transform.position,Quaternion.identity);
yield return new WaitForSeconds(1);
}
while(transform.position.x!=Player.transform.position.x){
transform.position=Vector3.Lerp(transform.position,Player.transform.position,Time.deltaTime);
}
}
}
}
i want to know what wrong with my code if that the reason for freezing plus player and target are assigned in the inspector. i also want a solution that is easily to change and keep the first while loop