Jump to content

How to time frames to make it completely predictible and smooth on all framerates


Wardzr
 Share

Recommended Posts

I'm working on a personal project where a simple sprite makes its way down a path aided by a simple physics engine. I need the animation to be completely predictable so that I can set an end state (say, sprite.y > 2000) and given the same start state, the sprite will take the exact same path and reach the exact same end state every single time, regardless of frame rate or lag. This first part I've easily solved by just tying it to requestAnimationFrame and not using any delta in my calculations, thus, every frame is completely determined by the previous frame with no wiggle room and the system is completely deterministic. However as you might guess this means that if I run my animation at 30fps it will look like it's slowed down, and if I run it at 120, it looks like it's sped up.

I can make it look smooth on all framerates by either imposing my own timer or actually using the delta in my movement calculations, but then the system stops being completely deterministic. What's the best way of making it look at least OK on all framerates while keeping it completely deterministic? 

 

Edited by Wardzr
Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...