Hello guys, i’m making my own character controller and physics, and currently, the final line of my script is just like this:
myTransform.position = Vector3.Lerp(myTransform.position,(myTransform.position + (myTransform.rotation * finalmovement)),0.8);
that finalmovement is a Vector3 that i get after calculating the physics and player inputs, to see where the character is gonna move.
The problem comes in the last part of the line, where i have to put the “time”. Currently, i’m not usign Time.deltaTime, and its working fine, if I creaty a build and play it, the movement is smooth, and even if i test in other PCs, the movement continues the same. That’s nice. In the editor mode, however, its not smooth and sometimes its gets very laggy. That’s bad, because I have to test everything via build & run.
I tried using Time.deltaTime, but the movement differs greatly from the editor and the build.
using for exemple, 40 * Time.deltaTime, in the editor, the character moves very fast, but in the build, it barely moves.
Can someone explain me why this happens? I tought using Time.deltaTime would give the same results, independent of the frame rate ( that is slower in the editor ).
And wich one is best when making this kind of precise movement?
Thanks in advance!
EDIT
Acutally, i do use Time.deltaTime in my code, but not on the Lerp itself
I use time.deltaTime to “find” the values, something like this:
finalmovement.y -= gravity * Time.deltaTime
and after that i do the lerp without Time.deltaTime
does will guarantee me that the speed is the same in every computer?