How I can using the physics and DT correctly?

Get help using Construct 2

Post » Thu Mar 07, 2013 10:04 pm

I am trying to create a game with physic, but I have seen que there's a problem with the frame rate and that I should to use the dt variable. So I am trying some like this:

Force:200*dt

Impulse:200*dt

but I do not sure, if is the correct way.
could you help me? shimo2013-03-07 22:06:12
B
14
S
4
G
2
Posts: 109
Reputation: 2,679

Post » Fri Mar 08, 2013 8:58 am

I would first do some searching in the manual and tutorials. Or if you want, post your capx and maybe some physics gurus can assist.
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,428

Post » Fri Mar 08, 2013 12:20 pm

@shimo

While developing my main game, where have a simple and old (dusted) sample on my signature, I has many problems dealing with DT.

So, what I had as problem, with my full custom movement system, was the player going into walls, because the frame rate update can variable and the system check the collision on each frame update, but if your sprite is in the eminence of a collision, and the frame rate drop down fast, the sprite can jump a large space in a short time, and when the system check it up, the sprite will be inside a wall...

After things like this, I started to use the platform behavior and work around all the other situations by attaching invisible sprites over the player, where I did custom movement system for each sprite, selecting them to be the main movement system as desired.

Another situation where the DT make my brain burn was while doing a simple car race. I did all the rotation of the AI using the DT as a multiplier, like you did, and I got low frame rates while playing on my smartphone (because of the physics), so, the AI started to miss the direction and go through turns, was hilarious, but serious sufficient to force myself to abandon the DT system.

Now, I just make it without DT and the system update right, but when the frame rate come down, the screen will show the AI doing a teleportation..
ImageImageImageImageImageImage
B
93
S
20
G
13
Posts: 1,217
Reputation: 18,996

Post » Fri Mar 08, 2013 4:43 pm

Physics doesn't and can't use dt effectivly

The nature of Box2D is that it's performance is dependent on the binary it's running on. Which means that the amount of CPU cycles spent on the physics determine the results.(cough why cutting down the fps to a desired level can influence our logic time cough)

However Box2D has a had a few tutorials to fix the timestep for it to work across different cpu/binaries
http://gafferongames.com/game-physics/fix-your-timestep/

unfortunantly C2 implementation lacks enough functionality exposed to be able to manually do this in an event sheet. From what I can tell :|jayderyu2013-03-08 17:18:47
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Fri Mar 08, 2013 6:25 pm

Physics will use dt if you use the 'Set stepping mode' action and choose 'framerate independent' (which means uses dt). By common request it is not the default because it adds random variation to games which can make them act differently each time from the same set up.

You don't need to use dt on impulses. I don't think you need to use dt on forces either, but I'm not sure...
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Fri Mar 08, 2013 10:58 pm

Ok thank you everybody, @jayderyu and @TELLES0808 your advice and experience will be useful me. @BluePhaze this is the cap, You say me if works in your computer :).

http://dl.dropbox.com/u/60873147/ExampleDtandPhysics.capx

@Ashley your advice is just that I need. Thank you so much
B
14
S
4
G
2
Posts: 109
Reputation: 2,679


Return to How do I....?

Who is online

Users browsing this forum: DonpatchXD, SpartCrafter and 28 guests