LERP function

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

Hi Othman,

Have you already tried to add Debug.Logs to your code to see what is going on during runtime? If the second lerp breaks, make a value has not been reset.


See also:

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms