Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Can't use Vector3 variables in Vector3.Lerp?

Discussion in 'Scripting' started by Username0101, Sep 20, 2015.

  1. Username0101

    Username0101

    Joined:
    Sep 3, 2015
    Posts:
    18
    http://pastebin.com/NbB3qJvB

    There's not a lot of required background here :|

    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?
     
  2. HiddenMonk

    HiddenMonk

    Joined:
    Dec 19, 2014
    Posts:
    987
    I dont understand what you are doing here
    Code (CSharp):
    1.   transform.position = Vector3.Lerp((Transform)prev.position, (Transform)MovingTo.position, (float)i);
    Would this not work?
    Code (CSharp):
    1.    transform.position = Vector3.Lerp(prev, MovingTo, i);
     
    Username0101 and Kiwasi like this.
  3. Username0101

    Username0101

    Joined:
    Sep 3, 2015
    Posts:
    18
    When you pointed this exact line out, I noticed which mistake I made.
     
  4. SharrTZaw

    SharrTZaw

    Joined:
    Mar 30, 2019
    Posts:
    13
    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);
     
  5. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,294
    Lerp. Its Lerp, not lerp.

    C# is case sensitive.
     
    TaleOf4Gamers likes this.