How to Make physices object stemping mode fixed and frame independent at the same time?

0 favourites
  • 5 posts
From the Asset Store
Selection frame like in RTS games, works both on mobile and desktop devices.
  • Hi,

    I'm working on a simple ball physics game, for this, I'm looking for a way to make the player ball's physics stepping mode fixed and frame-independent at the same time.

    I want to ensure that the player physics object not only behaves consistently regardless of any hardware limitations but also moves at the same speed regardless of the players screen refresh rate. Is this possible in any way?

    I have been working to solve this problem for some time now, and fortunately, I found out that Construct has built-in events where we can set the physics object's world stepping mode to fixed and another event where I can set it to be frame-independent. The problem arises only when I use both of these events simultaneously, even though they are triggered by two different events.

    Following is a screenshot of this. Apologies in advance if this topic is already covered in the forum; from what I've searched, I have not been able to find it. I hope someone would be able to guide me on this. Thanks in advance.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • They can’t be both simultaneously with the physics behavior. Since events run top down it will have framerate independent set.

    Unfortunately you can’t do what you’re after with the physics behavior. With a fixed step the simulation will be consistent yet the speed will vary with the frame rate, and the other setting makes the speed appear the same yet the simulation won’t be consistent.

    The underlying issue is in construct the events and behaviors run at the same rate as the screen refresh rate. We cannot limit the fps in construct either.

    A possible solution is to run the physics simulation at one rate, and interpolate the positions so it can be displayed at the screen refresh rate. It’s easier said than done though. You couldn’t utilize the physics behavior to do that, instead you’d need to use a physics library via JavaScript or roll your own physics with events. That is mainly so you can control when the physics is updated.

    The interpolation part will require you to have x,y,angle for the current frame and the next one for each object.

    Overall that’s all fairly low level. Construct isn’t currently designed to make something like that easy. General thought is to just use frame rate independent mode and just tolerate inconsistencies in the simulation. If you need more accurate simulation you’d need to do something else more complex unfortunately.

  • Thanks for the update, greatly appreciate it.

    It's unfortunate that Construct doesn't seem to support such a basic feature. Unfortunately, I personally I'm not that technically proficient enough to execute things in the way you mentioned unfortuantually. :(

    I have been breaking my head over this for a long time, at least now I know. :)

    As I was reading your message, I was thinking of a possible solution of having two physics objects that I can link together using Hierarchy, and then set physics stepping mode to fixed for one and frame-independent for the other. Do you think something like that could actually work?

  • I mean you can try it. Sounds like they’d fight each other.

  • Hmm... got it. I understand what you mean.

    To implement this properly, I think I will be required to do a lot more work on my end because of how everything has been set up within my project. In this case case, I think it would be better if I hold off on implementing it for now. If I ever get the opportunity to try this, I will make sure to document my findings here.

    Thanks once again for your input. :)

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