Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
box 2d world:step(..) fixed time steps — Gideros Forum

box 2d world:step(..) fixed time steps

GregBUGGregBUG Guru
edited January 2012 in Game & application design
hello!
hi guys! in my game i'm using a fixed time step for physics (according with the box2d manual) with a value of 1/60 sec.
the problem is that if i test the game an a slow device the physics is a bit slow...

reading on the net there are some solution with some mixed fixed/variable time steps i tested some but with bad results...
someone had any hint/code/example for solving this problem? :)

box2d manual says that the best value is normally 1/60 and using a variable time step is not a good idea... :(
TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
www.tntengine.com

Comments

  • atilimatilim Maintainer
    One solution can be using smoothed time steps. The example Hardware/Accelerometer uses low pass filtering to smooth the noisy accelerometer input. If you apply low pass filtering to event.deltaTime, you can achieve nearly constant time steps.

    Also there is a great explanation here: http://bitsquid.blogspot.com/2010/10/time-step-smoothing.html

    Likes: MikeHart, GregBUG

    +1 -1 (+2 / -0 )Share on Facebook
  • GregBUGGregBUG Guru
    edited January 2012
    ok.
    just tested and work fine... (by applying a filter on deltatime) :D

    but i need to redefine all the forces applied to the objects. (according with filtered deltatime)

    when a i go home (now i'm at work) i'll test in more detail.

    thank atilim for the tips.

    I will keep you informed. >:)
    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
  • GregBUGGregBUG Guru
    edited January 2012
    just for info....


    works great!

    using filtering on deltatime with a filter value of 0.4 and filtering all the forces applied to the objects.
    		fdt = event.deltaTime * lowfilter + fdt * (1 - lowfilter)
    		world:step(fdt, 6, 3)
    and on eli object
    	--if player touch the screen powerup (only if not collision with birds) ..
    	if (inTouch) and (eliBirdCollision == false) then
    		self.eli_body:applyLinearImpulse(0, -52*fdt , self.eli_px+14, self.eli_py)
    		eliSpeed = 2
    	else
    		-- else powerdown eli...
    		self.eli_body:applyLinearImpulse(0, -38*fdt , self.eli_px+14, self.eli_py)
    		eliSpeed = 1
    	end
    i just needed to increase
    velocity from 2 to 6 in "world:step(fdt, 6, 3)" because on low frame became instable...

    thanks!!!

    Likes: atilim, gorkem

    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
    +1 -1 (+2 / -0 )Share on Facebook
Sign In or Register to comment.