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 / Using StepPhysics breaks physics forces

Author
Message
Yaro
10
Years of Service
User Offline
Joined: 29th Mar 2014
Location:
Posted: 27th Jun 2015 23:43
I recently tried using StepPhysics(1.0/60.0) to make my game deterministic, but when I do objects I used to move with SetSpritePhysicsForce no longer work. When I comment out the StepPhysics line it works correctly. Objects that I move with SetSpritePhysicsImpulse still work as intended. Has anybody encountered this problem before? Is there a work around?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 28th Jun 2015 10:40
StepPhysics is called internally anyway during the Update2D call. Does the same thing happen if you use Update2D? If not it could be there is a bug in StepPhysics...

Using AppGameKit V2 Tier 1
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 28th Jun 2015 12:54
it works, but this stepphysics must behind this command.


AGK 108 (B)19 + AppGameKit (Steam) V2 Beta .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Yaro
10
Years of Service
User Offline
Joined: 29th Mar 2014
Location:
Posted: 29th Jun 2015 02:14
Thanks Markus, moving it to the end of the frame made it work! Not sure if it should be treated as a bug or if it should just be documented that it needs to be called after forces/impulses.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 29th Jun 2015 09:47
I'm not sure why creating forces and impulses would not work after calling stepPhysics as they should just be applied during the next loop... can you provide example code?

Using AppGameKit V2 Tier 1
Impetus73
12
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 29th Jun 2015 10:04
I guess there is a rendering pipeline, that flushes after every physics sync, in the physics system?

----------------
AGK programmer
Did Amiga / AMOS programming in the 90's.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 29th Jun 2015 11:07
Quote: "I guess there is a rendering pipeline, that flushes after every physics sync, in the physics system?"

Yes but if he is applying the forces after StepPhysics then I would expect the force to be applied next time StepPhysics is called... unless something in the general Sync or Update does it. That's why I would like to see an example to try to track the bug down.

Using AppGameKit V2 Tier 1
Impetus73
12
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 29th Jun 2015 13:16
I just think it would be best to always call all the sync commands at the very end of the loop, with the sync() command last.

----------------
AGK programmer
Did Amiga / AMOS programming in the 90's.
Yaro
10
Years of Service
User Offline
Joined: 29th Mar 2014
Location:
Posted: 1st Jul 2015 05:14
I tried to isolate it but then it wasn't working at all even when I did it right before the sync. I got kind of deep in some refactoring since this, after I clean that up I'll try to get something usable.
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 1st Jul 2015 17:56
Sync was accidentally clearing forces even when it didn't call StepPhysics itself. I'll change this for the next version so forces will only be cleared once, after the physics has been stepped.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Jul 2015 20:29
Awesome thanks Paul!

Using AppGameKit V2 Tier 1

Login to post a reply

Server time is: 2024-04-18 19:51:08
Your offset time is: 2024-04-18 19:51:08