- Home /
BCE0023 error
BCE0023: No appropriate version of 'UnityEngine.Mathf.SmoothDamp' for the argument list '(float, System.Object, float)' was found. I am getting this error from my script:
var cameraObject : GameObject;
var targetXRotation : float;
var targetYRotation : float;
var targetXRotationV : float;
var targetYRotationV : float;
var rotateSpeed : float = 0.2;
var holdHeight : float = -0.2;
var holdSide : float = 0.2;
function Update () {
transform.position = cameraObject.transform.position + (Quaternion.Euler(0,targetYRotation,0) * Vector3(holdSide, holdHeight, 0));
targetXRotation = Mathf.SmoothDamp( targetXRotation, cameraObject.GetComponent(MouseLook).xRotation.targetXRotationV, rotateSpeed);
targetYRotation = Mathf.SmoothDamp( targetYRotation, cameraObject.GetComponent(MouseLook).yRotation.targetYRotationV, rotateSpeed);
transform.rotation = Quaternion.Euler(targetXRotation, targetYRotation,0);
}
why is this?
Answer by Brian Stone · Jul 06, 2012 at 03:58 AM
The error message tells you exactly why. Because targetXRotationV and targetYRotationV are "System.Object" references but SmoothDamp() expects them to be of type "float". This is documented.
http://docs.unity3d.com/Documentation/ScriptReference/Mathf.SmoothDamp.html
static function SmoothDamp (current : float, target : float, ref currentVelocity : float, smoothTime : float, maxSpeed : float = Mathf.Infinity, deltaTime : float = Time.deltaTime) : float
You need to look at what type those variables are and see if you can cast them to float. Simple as that.
Answer by aldonaletto · Jul 06, 2012 at 02:57 AM
xRotation.targetXRotationV and yRotation.targetYRotationV don't exist in the original MouseLook.cs script - xRotation and yRotation are just float variables, thus they could not reference anything else.
Maybe you should use this instead:
...
var mLook: MouseLook = cameraObject.GetComponent(MouseLook);
targetXRotation = Mathf.SmoothDamp(targetXRotation, mLook.xRotation, rotateSpeed);
targetYRotation = Mathf.SmoothDamp(targetYRotation, mLook.yRotation, rotateSpeed);
...
NOTE: This will only work if Axes = MouseXAndY in the MouseLook script instance - xRotation isn't used when MouseX or MouseY are selected.
Your answer
![](https://koobas.hobune.stream/wayback/20220613073757im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
GameObject is already being activated or desactivated 2 Answers
How to change variables on a new gameobject's script 1 Answer
The referenced script on this Behaviour is missing! non-existant GameObject 0 Answers
Error in Android Export 0 Answers
What does "Couldn't find matching instance in prefab" mean? 2 Answers