- Home /
my unity is freezing when adding prefab to script
unity keep freezing when ever i add my players prefab to the script. after i press the play button the game just sorta loads then fails and shuts down.... i dont know why or what the issue is any ideas would help.
// T1=tech 1 M=max C=current H=health E=energy private var T1MH : float = 100; private var T1CH : float = 100; private var T1ME = 100; private var T1CE = 100; var playerpref : Transform; var Regen : float = 1; private var dead = false;
function OnGUI(){ GUI.Label(Rect(500,775,150,150),"Health"); GUI.Label(Rect(115,10,150,180), T1CH+"/"+T1MH); GUI.Label(Rect(10,40,150,150),"Energy"); GUI.Label(Rect(115,40,150,180), T1CE+"/"+T1ME); }
function Awake () {
Instantiate (playerpref);
}
function Update(){
// dead equals true and desotry game object if (dead){ Destroy(gameObject.FindWithTag("playerpref")); WaitForSeconds(2); Instantiate(playerpref); }
//makes dead true if (T1CH <= 0.0) { dead = true; }
// makes T1CH stop at 0 if (T1CH < 1) { T1CH = 0.0; }
//regen if(T1CH < T1MH){ T1CH += Regen * Time.deltaTime; } //Admin Dmg if (Input.GetKeyDown(KeyCode.I)) { T1CH -= 50; Debug.Log("You have Taken Damage!"); } }
Answer by networkZombie · Mar 17, 2011 at 04:40 PM
you cant have waitforseconds in function update
also i dont think your instantiate would work properly because you didn't declare playerpref
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
How to Instantiate Custom Class 2 Answers
Unity fire1 prefab in code 2 Answers
Movement script trouble 0 Answers
unity web player has stopped responding 0 Answers