# How to Lerp?

**URL:** <https://discussions.unity.com/t/how-to-lerp/566531>\
**Category:** Scripting\
**Tags:** Scripting\
**Created:** [February 7, 2015, 5:50am UTC](https://discussions.unity.com/t/how-to-lerp/566531 "2015-02-07T05:50:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BadSeedProductions](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/badseedproductions/32/245984_2.png) [@BadSeedProductions](https://discussions.unity.com/u/BadSeedProductions)\
**Post date:** [February 7, 2015, 5:50am UTC](https://discussions.unity.com/t/how-to-lerp/566531/1 "2015-02-07T05:50:49Z")

</div>

How can I lerp this, C# keeps giving me errors upon errors 😡, I have no clue, someone please help!

void SetTransformY(float n){  
transform.position = new Vector3(transform.position.x, n, transform.position.z);  
}  
// Update is called once per frame  
void Update () {  
if(NetworkManager.rocketButtonState == 0){  
SetTransformY(1.0f);  
}  
else if(NetworkManager.rocketButtonState == 1){  
SetTransformY(0.2f);

}  
else if(NetworkManager.rocketButtonState \>= 2){  
SetTransformY(0.05f);

}  
}

All I want to do is “simply” Lerp the y positions from one state to the other. Is this possible?

---

<div class="post-metadata">

**Author:** ![BenZed](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/benzed/32/346813_2.png) [@BenZed](https://discussions.unity.com/u/BenZed)\
**Post date:** [February 7, 2015, 6:42am UTC](https://discussions.unity.com/t/how-to-lerp/566531/2 "2015-02-07T06:42:14Z")

</div>

First of all, please use code tags.  
Secondly, what errors is it giving? Detail them.  
Thirdly, you don’t use the Lerp function anywhere, so why would you expect it to do so?

```csharp
void Update() {
   
    Vector3 target = new Vector3(transform.x, HeightFromRocketState, transform.z);
    transform.position = Vector3.Lerp(transform.position, target, Time.deltaTime);

}

float HeightFromRocketState {
    get {
   
        switch (NetworkManager.rocketButtonState) {
            case 0:
            return 1f;
           
            case 1:
            return 0.2f;
           
            case 2:
            return 2f;
       }   
    }
}

```
