Hello, I wanna make a connection between my playerController and my EnemyAI script, and i don't know where it's going wrong! This is the snippet: Code (csharp): if(curTarget != null) { var eAI : EnemyAI = curTarget.GetComponent("EnemyAI"); GUI.DrawTexture(Rect(0,150,500,150), EnemyGUI); GUI.Label(Rect(201,39,228,17), eAI.monsterName); }
Neither do I. A good start would be describing what you want the code to do and what it is actually doing - how it is failing.
My guess would be that curTarget does not have a EnemyAI component attached. I would check for eAI being a null value before doing anything with it. If it's not null and you can't get .monsterName then maybe that is not set.
plz read this before posting. http://forum.unity3d.com/threads/97...-in-the-scripting-section?p=638874#post638874