Physics behave differently on each device

1 favourites
  • 10 posts
From the Asset Store
A futuristic device, can be used as radarscreen, optionscreen, infodisplay, research device, ...
  • I am having an issue with physics in my game, revolute joints more precisely.

    On my desktop when I simulate a rope swing, everything is behaving how I want, subtle. When I test it remotely on my cellphone everything is different, gravity seems lower and ropes are swinging more aggressive.

    Can someone explain to my why is this happening?

  • Ok, apparently it's because different refresh rate, on computer it's 144hz and it gives around 120fps, and on cellphone I am getting fixed 60fps

    So, how can I limit framerate in Construct 3, to have fixed fps, to achieve almost exact physics behavior since this is causing the problem while testing the game.

  • You have to set physics mode to frame rate independent. Even then you probably have to adjust gravity and/or some forces slightly to compensate which I have not tried yet, but I assume some trial and error involved.

    So for example if gravity is set to 10 and works fine on your PC, try setting it to 12 before testing it on your phone. When you find a setting that makes things work roughly the same on both devices, then you can figure out a ratio between frame rates and physics settings. Final step, when game starts get the frame rate of players's device and adjust physics settings accordingly.

    I have not done this yet actually because I have not had major issues with this, but that would be my workaround

  • Physics defaults to framerate dependent, because around the time it was first introduced (and this is going back years), people had issues with making deterministic physics. The problem with framerate independent physics is because the time step has small random variations due to timer imprecision, it can result in random variations in physics simulations. This resulted in bug reports like "my tower of physics objects falls down a different way every time". People wanted their physics simulations to be predictable, which is what you get when using a fixed time step, so I (with some unease, knowing the downsides of fixed time steps) changed it to default to fixed. The downside of a fixed time step is, predictably, that it's framerate dependent, so now the physics simulation speed depends on the display refresh rate.

    Now that different display rates are more common, the default Physics setting probably needs to be changed back to framerate independent. But now we have the problem of figuring out a way to do that without breaking all existing projects which use the default and rely on deterministic physics.

  • Thanks for explanation guys!

    Ashley, I am coming from different game engine so I have to ask, are all physics objects in Construct sharing one box2D engine? To make it more clear, in ClickTeam Fusion I can create more physics engine with different set of rules and then I can say to each sprite/object which physics (engine) rule to follow.

  • With Construct's physics all objects share the same Box2D world, which is what I think you mean? I'm not sure why it would be useful to create different Box2D worlds, because AFAIK objects in different worlds cannot interact with each other at all. And you can already use different settings on different physics objects, so it doesn't seem necessary to use different worlds to achieve that.

  • Ashley For me it's just organizational thing using more than one Box2D world. I can setup character on one Box2D, and assets that needs to explode all over the place on another. So most changes I am doing is on Box2D itself without need to tweak each asset that belongs to different group/family, and as a benefit, those Box2D worlds don't collide.

    Speaking of collision, I currently have more than 30 pieces that are not suppose to collide physically. The fastest way I figure out how to do this is: put all 30 pieces in one family, in event editor select each peace and switching off physics collision with this family. However, that's 30 actions, and family doesn't hold physical collision action, is there any faster way to do this?

  • I'm still not sure what you mean abot Box2D worlds. I think maybe you're talking about something else?

    However, that's 30 actions, and family doesn't hold physical collision action, is there any faster way to do this?

    Add the behavior to the family, then the physics actions appear for the family.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I'm still not sure what you mean abot Box2D worlds. I think maybe you're talking about something else?

    I meant to say more than one Box2D engine, but in Construct terms I guess you are calling it Box2D world.

    In another engine I was very occasionally using more than one Box2D "engine": With one Box2D I am setting global gravity that is applied for main character, with second created Box2D I am setting global gravity for big amount of assets. This way I am changing gravity and forces for dozens of objects in two text boxes only, and also my character is not affected by forces of assets from another Box2D engine.

  • You shouldn't need different worlds to do that. The existing features should allow you to do all that already, with collision disabling and per-instance forces.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)