Jump to content

Framerate-independent controller movement?


tec.imp
 Share

Recommended Posts

Hey there.

 

The Wiki gives some definition of the value AppSpeed returns (60/UPS?), and in particular that it is to be used to achieve framerate-independent movement. From looking at the values returned, they seem to also be averaged/curved in some way.

 

UpdateController produces movement speeds subject to framerate, with faster framerates producing slower movement. Multiplying the input movement vectors of UpdateController with AppSpeed produces similar results: faster framerates produce slower movements. Then again, multiplying the movement vectors with my own delta time produces this effect too, leaving me to conclude that UpdateController already factors time into its calculations by its own.

 

This leaves me with UpdateWorld and the step size I supply - AppSpeed - which I assume is the abovementioned time factor that controllers use. However, not only does UpdateWorld(AppSpeed) not produce framerate-independent movement at controllers, to my surprise it does not seem to produce framerate-independent updates at all. This becomes evident in the fact that gravity (as measured in the speed of falling objects) is subject to framerate as well (again, faster framerates produce slower falling objects). :blink:

 

So, how am I to achieve framerate independent movement using controllers in Leadwerks, and for that matter, world updates?

 

Thanks in advance.

 

 

Mfg Imp

Link to comment
Share on other sites

They do work, although I can't say if they work as intended. The discrepancy in resulting movement speeds (for controllers as well as for objects falling due to gravity) becomes quite apparent to the naked eye with framerates of 60 and 250, which I achieve by enabling/disabling vsync.

 

Thanks for trying to help.

 

 

Mfg Imp

Link to comment
Share on other sites

When disabling vsync things do move to fast for like 1 second because the AppSpeed has to recalculate.

But except for that, objects fall at the same speed at no matter what framerate for me.

 

Really can't say why it doesn't work for you. Make sure UpdateAppTime() and UpdateWorld() are called once and only once per loop.

Link to comment
Share on other sites

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.

 Share

×
×
  • Create New...