- Home /
"MissingMethodException: Method not found:" (Javascript)
I am trying to make a button activated spawn point using "Spawner - Free 1.7" and I am having trouble. I am modifying the code of a lift button already implemented in my scene.
var Spawner : GameObject;
var UseSound : AudioClip;
private var canUse : boolean = false;
var waitTime : float; //Time till Spawner activate
private var IRuzspiests : boolean = false;
var SpawnerID : float;
function Activate () {
Spawner.EnableSpawner(int.SpawnerID);
audio.PlayOneShot(UseSound, 1.0 / audio.volume);
}
function Deactivate (){
Spawner.DisableSpawner(int.SpawnerID);
audio.PlayOneShot(UseSound, 1.0 / audio.volume);
}
function ApplyDamage(){
Action ();
}
function Action (){
if (!canUse && !IRuzspiests){
Activate();
canUse = true;
IRuzspiests = true;
yield WaitForSeconds(waitTime);
IRuzspiests = false;
}else{
if (canUse && !IRuzspiests){
Deactivate();
canUse = false;
IRuzspiests = true;
yield WaitForSeconds(waitTime);
IRuzspiests = false;
}
}
}
and here is the error
MissingMethodException: Method not found: 'UnityEngine.GameObject.EnableSpawner'.
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+<Invoke>c__AnonStorey14.<>m__7 ()
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)
SpawnTriggerScript.Activate () (at Assets/Resources/OldScripts/LiftScripts/SpawnTriggerScript.js:11)
SpawnTriggerScript+$Action$404+$.MoveNext () (at Assets/Resources/OldScripts/LiftScripts/SpawnTriggerScript.js:26)
UnityEngine.GameObject:BroadcastMessage(String)
FPSCcameraScript:Update() (at Assets/Resources/OldScripts/Vehicle scripts/FPSCcameraScript.js:18)
If anyone could tell me what I need to do to get this to work, it would be much appreciated.
the documentation on how to use the spawner is here: https://dl.dropbox.com/u/43996324/Unity/Spawner/html/functions.html
Answer by flaviusxvii · Feb 11, 2013 at 03:46 AM
Firstly, "Spawner" is the name of a Class in this "Spawner" package. So you don't want to name a variable "Spawner". In fact, you just shouldn't name your variables with upper case letters at the beginning, it's almost universally the norm to name TYPES with upper case letters to start.
Secondly, Your variable "Spawner" is of type GameObject. GameObject doesn't not have a method called EnableSpawner. If you want to treat "Spawner" like some other type, then the variable will need to be that type. You should change
var Spawner : GameObject;
to
var spawner : Spawner;
Then you can call spawner.EnableSpawner all day long.
Thank you, it's obvious I am new to scripting, so thank you for helping.
Once i have var spawner : Spawner;
layed out, how do i define 'Spawner' as a type? Unity says it is not valid.
The package from the Dropbox link you gave had a Spawner in it. Did you import that?
Well that's too bad. Your issues here are fundamental program$$anonymous$$g concepts. Often it's tempting to use something someone else has written, but it can be more confusing in the long run. Especially if that code is full of bad habits. Try programs that are simpler in scope and work your way into more complicated concepts.
I actually figured out that I was calling in a namespace that was being compiled by unity AFTER the java was being compiled. Fixed the problem and everything works. Thank you for your help.
Your answer
Follow this Question
Related Questions
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Setting Scroll View Width GUILayout 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
null exception reference on animation Unity 3.5+ 2 Answers
Trying to get enemy to aim at the player and shoot at it 2 Answers