I seem to be unable to use the "less than or equal to" operator correctly, and was hoping someone would be able to tell me what I'm doing wrong in my use of it?
if (dist The above code compiles and runs but generates this error in the debug console. I suspect the first line is the important part.
MissingMethodException: Method not found: 'System.Single.op_LessThanOrEqual'.
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.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)
Boo.Lang.Runtime.RuntimeServices.InvokeBinaryOperator (System.String operatorName, System.Object lhs, System.Object rhs)
Rethrow as MissingMethodException: Less than or equal is not applicable to operands 'System.Single' and 'UnityEngine.Vector3'.
Boo.Lang.Runtime.RuntimeServices.InvokeBinaryOperator (System.String operatorName, System.Object lhs, System.Object rhs)
RigidbodyMovement_v2.FixedUpdate () (at Assets/RigidbodyMovement_v2.js:29)
asked
Jan 17 '12 at 08:41 PM
Sastrei
1
●
2
●
3
●
4
It would be interesting what type "dist" and "distancefromtarget" has... It's most likely one or both are not a simple type do not implement this operator. We need to see where those two variable are declared.
Neither one is typed (set using :?). They're declared outside of any functions at the top of the script.
That's the problem! Unity was not able to define which type they are at runtime, and produced that error. Define both as floats:
Maybe you have other errors after fixing this one - if so, let us know!
The error seems to have gone away now, many thanks!