Lerping on Y axis?
I'm not sure how to lerp so I used the docs to find an example, I can't seem to find a solution online to lerp on different axis instead of just on the X axis.
This is what I have at the moment:
public float minimumHeight = -3.5f;
public float maximumHeight = 3.5f;
static float midpointHeight = 0f;
transform.position = new Vector3(Mathf.Lerp(minimumHeight, maximumHeight, midpointHeight), 0, 0);
midpointHeight += 1f * Time.deltaTime;
if (Input.GetKeyDown (KeyCode.W)) {
if (midpointHeight > 1.0f){
float temp = maximumHeight;
maximumHeight = minimumHeight;
minimumHeight = temp;
midpointHeight = 0.0f;
Thanks
Comment
@Qek - What should happen? You want something to go from A to B once when key is pressed? Or you want something to ping-pong between two values?
Your answer
Follow this Question
Related Questions
Snake like movement in 2D space 0 Answers
How to move to a specific position in 2d game? 0 Answers
Rigid body vibrating? 0 Answers
Pressing both vertical and horizontal axis slows down my move speed 0 Answers
Vector3.Lerp not moving object backwards 0 Answers