Can't use Vector3 variables in Vector3.Lerp?

http://pastebin.com/NbB3qJvB

There’s not a lot of required background here :expressionless:

Assets/Scripts/Environment/asteroidMove.cs(44,75): error CS1061: Type UnityEngine.Vector3' does not contain a definition for position’ and no extension method position' of type UnityEngine.Vector3’ could be found (are you missing a using directive or an assembly reference?)

Assets/Scripts/Environment/asteroidMove.cs(44,105): error CS1061: Type UnityEngine.Vector3' does not contain a definition for position’ and no extension method position' of type UnityEngine.Vector3’ could be found (are you missing a using directive or an assembly reference?)

Assets/Scripts/Environment/asteroidMove.cs(44,54): error CS1502: The best overloaded method match for `UnityEngine.Vector3.Lerp(UnityEngine.Vector3, UnityEngine.Vector3, float)’ has some invalid arguments

Assets/Scripts/Environment/asteroidMove.cs(44,54): error CS1503: Argument #1' cannot convert object’ expression to type `UnityEngine.Vector3’

Can someone tell me what Unity is trying to say? (I know the obvious part, even though documentations have the same) Why can’t I do it, and how to fix it?

I dont understand what you are doing here

  transform.position = Vector3.Lerp((Transform)prev.position, (Transform)MovingTo.position, (float)i);

Would this not work?

   transform.position = Vector3.Lerp(prev, MovingTo, i);
2 Likes

When you pointed this exact line out, I noticed which mistake I made.

I write for my script in below and an error say that
.cs(237,47): error CS0117: ‘Vector3’ does not contain a definition for ‘lerp’
How can I fixed this problem? thank you.

target.position = UnityEngine.Vector3.lerp(target.position, new Vector3(0, 0.25f, 0), 2.0f * Time.deltaTime);

Lerp. Its Lerp, not lerp.

C# is case sensitive.

1 Like