So i’m trying to do a point and click movement of a single unit in a RTS fashon and I have set up this script. i get this error, I’m new to scripting so any help would be great
NullReferenceException: Object reference not set to an instance of an object
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)
selct and move.Update () (at Assets/selct and move.js:12)
This is the script
var speed : float = 20.0;
var move : boolean;
var wantedPosition : Vector3;
function Update () {
if ( Input.GetMouseButtonDown ( 1 ) ) {
var ray : Ray = Camera.Main.ScreenPointToRay ( Input.mousePosition );
var hit : RaycastHit;
if ( Physics.Raycast (ray, hit) ) {
move = true;
wantedPosition = hit.point + Vector3 ( 0.0, 30.0, 0.0 );
}
}
if ( move ) {
transform.LookAt ( wantedPosition );
transform.Translate ( Vector3.forward * Time.deltaTime * speed );
if ( Vector3.Distance ( transform.position, wantedPosition ) < 0.10 ) {
move = false;
}
}
}