Hi,
I have created a ghost system for a racing game, so I have positions values stored in an array, and I’m trying to move my object from one point to the other every 5 physic ticks. Given “physic tick per second” is set at 120, it means a gap of 1/24 of a second between each position, if my math is correct.
The motion is smooth, but for the ghost to be at the right position, I would need some_number to be set at a value I have frankly no idea how I can find. With trial and error I found that something around 3 is good, but not good enough, the object always seems to be off from a few tenth of a second.
So I’ve tried using a tween I trigger every 5 ticks :
First, 1/24 is 0.041, thats why your animation is super fast.
Second, you can use lerp function in a way:
time += delta / 2 #Replace with any number for making it slow, or multi for fast
time = clampf(time, 0.0, 1.0)
global_position = lerp(global_position, next_position, time)
But you need to reset the time variable to 0 while changing the next position.
Or use the lerp normally, just try to multiply the delta by lower values like this:
Ok, I fixed this.
First thing, I forgot that you should NEVER use 1/24 and instead use 1.0/24.0, otherwise Godot thinks you are using integers and always returns 0.
But it was still a bit choppy, so I simply doubled the amount of time between two position recording, anyway it had no reason being that precise.
Now it works, it shows the precise position while being silky smooth.