function Start(){
var enemyUnits = GameObject.FindGameObjectsWithTag(“Enemy”);
var enemyAIScript = enemyUnits.GetComponent(EnemyAI);
alert = false;
caution = false;
normal = true;
}
function Update(){
enemyAIScript.SendMessage("Hunt");
enemyAIScript.go = false;
}
Hi. Admittedly this is a repost but my last post got no answers on it so oh well. I’ve go this script ^^^ but when I play it in the editor enemyAIScipt returns nothing. A script called EnemyAI is definetely attached to it but it still doesn’t return anything. I got this error in the editor
MissingMethodException: UnityEngine.GameObject.GetComponent
Boo.Lang.Runtime.DynamicDispatching.MethodDispatcherFactory.ProduceExtensionDispatcher ()
Boo.Lang.Runtime.DynamicDispatching.MethodDispatcherFactory.Create ()
Boo.Lang.Runtime.RuntimeServices.DoCreateMethodDispatcher (System.Object target, System.Type targetType, System.String name, System.Object args)
Boo.Lang.Runtime.RuntimeServices.CreateMethodDispatcher (System.Object target, System.String name, System.Object args)
Boo.Lang.Runtime.RuntimeServices+c__AnonStorey15.<>m__9 ()
Boo.Lang.Runtime.DynamicDispatching.DispatcherCache.Get (Boo.Lang.Runtime.DynamicDispatching.DispatcherKey key, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.String cacheKeyName, System.Type cacheKeyTypes, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.Object args, System.String cacheKeyName, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
Boo.Lang.Runtime.RuntimeServices.Invoke (System.Object target, System.String name, System.Object args)
UnityScript.Lang.UnityRuntimeServices.Invoke (System.Object target, System.String name, System.Object args, System.Type scriptBaseType)
ControlAI.Start () (at Assets/BLAM/Enemies/RegularUnits/ControlAI.js:18)
I think I’ using GetComponent wrong but the unity tutorials for JS don’t discuss getting scripts so I’m not sure. Help