I was going through the tornadotwins tutorials on youtube, and for some reason their scripts keep giving me errors?
I solved most of them but 2, a Missing Method Exception and Null Reference Exception.
The Missing Method Exception applied to my Turret control script, heres the script
var LookAtTarget : Transform;
var damp : float = 6.0;
var bullitPrefab : Transform;
var savedTime = 0;
function Update ()
{
if(LookAtTarget)
{
var rotate = Quaternion.LookRotation(LookAtTarget.position - transform.position);
transform.rotation = Quaternion.Slerp(transform.rotation, rotate, Time.deltaTime * damp);
var seconds : int = Time.time;
var oddeven = (seconds % 2);
if(oddeven)
Shoot(seconds);
transform.LookAt(LookAtTarget);
}
}
function Shoot(seconds)
{
if(seconds!=savedTime)
{
var bullit = Instantiate(bullitPrefab,transform.Find("TurretSpawnPoint").transform.position , Quaternion.identity);
bullit.rigidbody.Addforce(transform.forward * 1000);
}
savedTime=seconds;
}
And the error:
MissingMethodException: Method not
found:
‘UnityEngine.Rigidbody.Addforce’.
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__AnonStorey12.m__6
()
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)
TurretControl.Shoot (System.Object
seconds) (at
Assets/Scripts/TurretControl.js:26)
TurretControl.Update () (at
Assets/Scripts/TurretControl.js:15)Assets/Scripts/TurretControl.js:15)
The next is a NullReferenceException for my MoveAround Script, heres the script, It took a while to get a solution for this. I dont know why the scripts arent working for me, they seem to work fine for most people…
var speed = 3.0;
var rotateSpeed = 3.0;
function Update ()
{
var controller : CharacterController = GetComponent(CharacterController);
var forward = transform.TransformDirection(Vector3.forward);
var curSpeed = speed * Input.GetAxis ("Vertical");
controller.SimpleMove(forward * curSpeed);
transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
if(Input.GetButtonDown("Fire1"))
{
Instantiate (GameObject.Find("BubblePrefab"),
GameObject.Find("SpawnPoint").transform.position,
Quaternion.identity);
}
}
@script RequireComponent(CharacterController)
And le error…
NullReferenceException
UnityEngine.Object.Internal_InstantiateSingle (UnityEngine.Object data, Vector3 pos, Quaternion rot) (at C:/BuildAgent/work/6bc5f79e0a4296d6/Runtime/ExportGenerated/Editor/BaseClass.cs:46)
UnityEngine.Object.Instantiate (UnityEngine.Object original, Vector3 position, Quaternion rotation) (at C:/BuildAgent/work/6bc5f79e0a4296d6/Runtime/ExportGenerated/Editor/BaseClass.cs:57)
MoveAround.Update () (at Assets/Scripts/MoveAround.js:15)