- Home /

# 4 Error on my script.

Scripts/aim 2.js(19,41): BCE0017: The best overload for the method 'UnityEngine.Vector3.Lerp(UnityEngine.Vector3, UnityEngine.Vector3, float)' is not compatible with the argument list '(UnityEngine.Quaternion, UnityEngine.Vector3, float)'.

Scripts/aim 2.js(19,41): BCE0022: Cannot convert 'UnityEngine.Vector3' to 'UnityEngine.Quaternion'.

Scripts/aim 2.js(25,41): BCE0017: The best overload for the method 'UnityEngine.Vector3.Lerp(UnityEngine.Vector3, UnityEngine.Vector3, float)' is not compatible with the argument list '(UnityEngine.Quaternion, UnityEngine.Vector3, float)'.

Scripts/aim 2.js(25,41): BCE0022: Cannot convert 'UnityEngine.Vector3' to 'UnityEngine.Quaternion'.

Can anyone fix these errors?

```
#pragma strict
var HipPose : Vector3;
var AimPose : Vector3;
var HipRot : Vector3;
var AimRot : Vector3;
var AimSpeed = 0.5;
function Start ()
{
transform.localPosition = HipPose;
}
function Update () {
if(Input.GetButton("Fire2"))
{
transform.localPosition = Vector3.Lerp(transform.localPosition, AimPose, AimSpeed * Time.deltaTime);
transform.localRotation = Vector3.Lerp(transform.localRotation, AimRot, AimSpeed * Time.deltaTime);
}
if(!Input.GetButton("Fire2"))
{
transform.localPosition = Vector3.Lerp(transform.localPosition, HipPose, AimSpeed * Time.deltaTime);
transform.localRotation = Vector3.Lerp(transform.localRotation, HipRot, AimSpeed * Time.deltaTime);
}
}
```

Use Quaternion.Lerp or the transform eular angles ins$$anonymous$$d of rotation. Rotation is a Quaternion, just as the error suggests.

Ok I don't really understand what I have to change so can you re-write my script and change the things that I'm supposed to?

**Answer** by thelackey3326
·
Jan 20, 2014 at 08:29 PM

Expanding on what iwaldrop said:

Lines 19 and 25 are where the problem lies. There it looks like you are trying to interpolate ("lerp") a rotation, which is a Quaternion. The error is that you are using *Vector3.Lerp()* where you should be using *Quaternion.Lerp()*.

```
transform.localRotation = Vector3.Lerp(transform.localRotation, AimRot, AimSpeed * Time.deltaTime);
```

For line 19, it should probably be:

```
transform.localRotation = Quaternion.Lerp(transform.localRotation, Quaternion.Euler(AimRot), AimSpeed * Time.deltaTime);
```

**Just as a side note**

Something you should keep in mind is that passing the value you want to interpolate as the *from* value will mean that the difference between from and to will become infinitely small but, theoretically, never quite reach zero. The effect is that the lerp will slow down over time but will never complete (if complete is the right word). It's not invalid, but it may not be the desired effect.

Alright thanks for helping me out as well, I'll try using this.

So I finally got time to try this but it doesn't work, I get this error;

/Scripts/aim 2.js(19,44): BCE0017: The best overload for the method 'UnityEngine.Quaternion.Lerp(UnityEngine.Quaternion, UnityEngine.Quaternion, float)' is not compatible with the argument list '(UnityEngine.Quaternion, UnityEngine.Vector3, float)'

/Scripts/aim 2.js(25,44): BCE0017: The best overload for the method 'UnityEngine.Quaternion.Lerp(UnityEngine.Quaternion, UnityEngine.Quaternion, float)' is not compatible with the argument list '(UnityEngine.Quaternion, UnityEngine.Vector3, float)'.

Yeah. That would happen if you used the above code, because AimRot is a Vector3. Poorly named variable, because Vectors describe points and angles while Quaternions describe rotations. A better name for 'AimRot' would be 'ai$$anonymous$$gEulerAngle'. You might consider storing a Quaternion (although I'm not sure how that would impact the rest of your code, depending on how much you assigned the rotation calling Quaternion.Euler would add up in lost frames). That bit aside, this line should work with your existing setup:

```
transform.localRotation = Quaternion.Lerp(transform.localRotation, Quaternion.Euler(AimRot), AimSpeed * Time.deltaTime);
```

As per the documentation, Quaternion.Euler returns a rotation that rotates z degrees around the z axis, x degrees around the x axis, and y degrees around the y axis (in that order).

Thank you for the help I'll have to try this out, I'll let you know if I have any problems. By the way I don't think it matters what the variable is called it's just short for aim rotation.

Of course it matters! :)

It's good program$$anonymous$$g practice for your (at least member) variable names to be meaningful. It's not a rotation, it's an angle. If it had been more clear then perhaps thelackey wouldn't have assumed it was a Quaternion. While it may not matter when only a single person is working on a code base, it is of utmost importance when multiple people are, and that the na$$anonymous$$g convention produces clear and meaningful information; self documenting code is the best kind.

Imagine getting someone else's code and not knowing what anything is because they just named things willy-billy off the top of their heads.

### Your answer

### Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.