hi im starting devloping my new game but i found a probleme using Lerp fuction , First of all my update :
private void Update() {
if(isRight){
MovePlayer(position[0],position[1]);
}
if(isLeft){
MovePlayer(position[1],position[0]);
}
i check if i clicked on the right or left then i launche de MovePlayer methode :
void MovePlayer(Vector3 positionArrive,Vector3 positionDepart){
elapsedTime += Time.deltaTime;
pourcentagedemouvement = elapsedTime / timeBetwenposition;
transform.position = Vector3.Lerp(positionArrive, positionDepart, pourcentagedemouvement);
Debug.Log(pourcentagedemouvement);
if(pourcentagedemouvement > 1 ){
return;}
}}
but when i play this scripts the first lerp is good , then it break totally , if anyone has the solution please help me , thank you