[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
Chipmunk Physics • View topic - Jumpy Player Movement

Jumpy Player Movement

Official forum for the .

Jumpy Player Movement

Postby xerver » Fri Jan 24, 2014 5:21 pm

I am using the JS port of Chipmunk2D in my game engine, and so far it is working great.

My only issue so far is trying to do top down player movement via a control body. I am getting some jumpy, micro-teleportation effects as the player moves around.

Code and more details can be found on my github issue post: https://github.com/josephg/Chipmunk-js/issues/26

I was using the frame-time as my time-step for the space.step() function, and when I changed it to a constant the issue became much less prevalent but still happens. I have narrowed it down to actual body position changes (not fps or some other issue). If you have any ideas as to what the issue is or need more info please let me know!

Thanks!

-Chad
xerver
 
Posts: 3
Joined: Fri Jan 24, 2014 1:01 pm

Re: Jumpy Player Movement

Postby LegoCylon » Sat Jan 25, 2014 12:05 pm

You may also want to add interpolation between the last position/rotation and the current position/rotation when rendering in case you get multiple frames between physics steps.
LegoCylon
 
Posts: 29
Joined: Wed May 09, 2012 12:06 am

Re: Jumpy Player Movement

Postby xerver » Sat Jan 25, 2014 3:16 pm

xerver
 
Posts: 3
Joined: Fri Jan 24, 2014 1:01 pm

Re: Jumpy Player Movement

Postby LegoCylon » Sat Jan 25, 2014 8:37 pm

You should be interpolating between physics steps since that's where your discrete movement is currently happening. Even with a high number of steps, it's always going to "jump" between steps because the calculations are only obtaining an instantaneous result.

Basically you'll want to remember the last position & rotation for each physics body before any of them are updated. You calculate the interpolation value based on the elapsed time between physics steps. Since your step is 1/60, you simply divide the elapsed time by (1/60) to get the result. Then simply use that result to calculate the linear-interpolation of the position and rotation. If the result is > 1 then you need to run a new physics step. The idea here is that the interpolation will match the time that the frames are rendered and you should not expect those to happen at a regular interval (although ideally they do).

Your choice of timer is also important. If you're on Windows, GetTickCount typically has a resolution worse than 15ms which means that you won't get very accurate times; you'll want to use something like QueryPerformanceCounter instead.
LegoCylon
 
Posts: 29
Joined: Wed May 09, 2012 12:06 am

Re: Jumpy Player Movement

Postby xerver » Mon Jan 27, 2014 12:30 pm

Thanks Lego!

This has solved my issue now that I am interpolating correctly. As far as timer accuracy, note that this is in JavaScript so my choices are limited.

Thanks again for the help!

-Chad
xerver
 
Posts: 3
Joined: Fri Jan 24, 2014 1:01 pm


Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 4 guests

cron