Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I correctly find my t when working with DeltaTimes?

Asked by
Edenojack 171
6 years ago

I am currently storing an ever growing series of positions in a table, From the Most recent [1] to the earliest entry [n] I know that the time between registering each of these positons will always be X

To smoothly lerp between them, I am using the Heartbeat element of RenderStepped which gives us a delta time. Using the delta time, knowing that time between positions will always be X, what should I be doing?

Code looks like this;

    totaldt = totaldt+dt--/X
    if totaldt > X then--if its over the deisred amount, we don't need
        totaldt = X-totaldt -- gives us a number thats <0>
    end
    if pos~=positions[1] then --If we changed our first entry (shifted all by one)
        pos=positions[1]
        total = X-totaldt
    end
    local t = totaldt/X -- exists between 0-1 (or slightly outside, but never massively.)
0
What are you trying to do? Mineloxer 187 — 6y
0
as said in the question, I am trying to smoothly lerp between points. From Positions[2] to Positions[1] Edenojack 171 — 6y
0
It is impossible to know that the time between each entry is exactly "X" - 'wait' doesn't wait that reliably. I can't decipher what you're trying to do, though, so I can't recommend a solution. (Idk if this would help, but) have you considered summing the delta times from Heartbeat together? chess123mate 5873 — 6y

Answer this question