Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / FPS, & Physics Movement

Author
Message
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 8th May 2015 13:16
Hi, So I'm a good way into my first 'real' game and I've noticed a little bit of a problem, basically its an angry birds type physics game but with an educational theme, I have a cannon that shoots a ball and knocks the blocks!, all works fine on windows and my S5 however on my S4 Mini its suffers a framerate drop when the device is busy syncing and stuff and this causes the ball to lose motion almost like massive wind resistance and falls very very short of the target

I launch the ball with the below function and let the physics engine take care of the rest ......




Is there anything I can do to make the physics movement tie in with the current framerate or do I need to update the balls position each frame?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 8th May 2015 13:35
The best way to deal with physics on multiple devices is NOT to tie it into the framerate. You are best to stick to a framerate of 60fps and update by a manual amount of 0.01666667.

So on setup SetSyncRate(60, 0) and before you sync StepPhysics(0.01666667).

That way the physics will react correctly even if the device slows the game down.

Using AppGameKit V2 Tier 1
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 8th May 2015 13:59
I'd have thought StepPhysics(GetFrameTime()) should keep things moving at the same rate regardless of fps. A little test here:





V2 T1 (Mostly)
Uzmadesign
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 8th May 2015 21:33 Edited at: 8th May 2015 21:40
Thanks for the tips guys, I did look at StepPhysics but as the manual said "Sync or Update will call it for you with the last frame time to allow the physics simulation to catch up in real time" I assumed it was taken care of, but it seems to have done the trick

EDIT: calling with GetFrameTime() produces the same result, like massive resistance, calling with a fixed '0.01666667' does the trick, even at extremely low frame rate the cannon ball makes its target ... eventually!! lol
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 9th May 2015 13:07
CJB, that would make sense but I've found if the framerate drops and the physics system updates larger periods of time the results become less consistent. Sounds crazy I know but we did a lot of experimenting when I was working for TGC and Paul suggested this was the best result possible.

Using AppGameKit V2 Tier 1

Login to post a reply

Server time is: 2024-06-29 02:51:58
Your offset time is: 2024-06-29 02:51:58