- Home /
setting variable in game object with instantiated object reference
Hello,
I have a "Main" game object that has a car list in it, when the player clicks "create server" I want to update this "Main" game objects car list...
The car list is called
Cars (and has a size and element 0)
in my prefab object, I have a carnetworkinit, that runs this script,
if (networkView.isMine) {
GetComponent("NetworkRigidbody").enabled = false; var themain : GameObject; themain = GameObject.Find("MAIN");
// themain.GetComponent("CarInput").Cars.Push (CarControl); // themain.GetComponent("CarInput").SwitchCar(2);
}
however, if I uncomment this code, (which I think is the problem) it says this error...
MissingMethodException: Method not found: 'CarControl[].Push'. 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_AnonStorey13.<>m_7 () Boo.Lang.Runtime.DynamicDispatching.DispatcherCache.Get (Boo.Lang.Runtime.DynamicDispatching.DispatcherKey key, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) Boo.Lang.Runtime.RuntimeServices.Dispatch (System.Object target, System.String cacheKeyName, System.Type[] cacheKeyTypes, System.Object[] args, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) Boo.Lang.Runtime.RuntimeServices.Dispatch (System.Object target, System.String cacheKeyName, System.Object[] args, 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) CarNetworkInit.OnNetworkInstantiate (NetworkMessageInfo msg) (at Assets/Networking Scripts/CarNetworkInit.js:12) UnityEngine.Network:Instantiate(Object, Vector3, Quaternion, Int32) CarSpawnPrefab:OnNetworkLoadedLevel() (at Assets/Networking Scripts/CarSpawnPrefab.js:10) UnityScript.Lang.UnityRuntimeServices:Invoke(Object, String, Object[], Type) ConnectGui:OnGUI() (at Assets/Networking Scripts/ConnectGui.js:34)
CarControl is the prefabs "car controller" script.. again, this might be the problem too.. I dunno..I don't want to put a "push" method into the car control script....
Anyone even have the foggiest what I just wrote?
Answer by ckfinite · Nov 30, 2010 at 06:33 PM
Try the Add function. It is basically saying that it has no idea what you are calling. Unity uses Mono instead of the normal EMCAS script implementation of JS, and mono uses .NET classes. It makes more sense from C#.