Lerp Problem
So, I have this simple script that makes a gameobject lerp on the X axis and it keeps getting stuck between two values that change depending on the start and end positions of the lerp and I don't know why, please help.
For example: 114.9, 115.1, 114.7, 115.3, 114.5, 115.0, 114.6
Here's the script:
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour
{
void Start(){}
void Update()
{
transform.position = Vector3.Lerp(new Vector3(100, 0, 0), new Vector3(1000, 0, 0), Time.deltaTime);
Debug.Log(transform.position);
}
}
Answer by Showny · Nov 20, 2016 at 05:29 PM
I figured it out, the start position of the the Vector3.Lerp needs to be the object position or at each frame it's going to restart the lerp.
Your answer
![](https://koobas.hobune.stream/wayback/20220612101010im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How do I achieve "inertial" camera movement for mouse look? 1 Answer
Vector3.Lerp not moving object backwards 0 Answers
Game object position is stuck when using mathf.sin,Object's position stuck when using Math.sin 0 Answers
Lerping at a constant rate? 2 Answers
Make color pulse every 2 seconds 1 Answer