Rotate/move based on DT

0 favourites
  • 3 posts
From the Asset Store
Simple resize and rotate events for any sprite, quick and easy event sheet that you can use for your own projects.
  • The only way I've ever moved objects manually is by using the update function, ie: "Every tick set position to self.x + 1" but I'm in a situation where I really need the object to move based on time (like if you slow down the time scale, the motion will also slow down). This is probably simple but I've never done it. What's the best way?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sushin - Very similar to what you have here, but you want to think in terms of an objects speed per second and then adjust according to dt.

    So in your example above - Every tick set position to self.x + 1 - you're basically saying the object is moving 60 pixels per second BUT only if you have a frame rate of 60 fps.

    To convert that to framerate independent movement, you would have the following:

    Every tick set position to self.x + (SPEED_PER_SECOND * dt)

    That calculates how far the character should move, based on their SPEED_PER_SECOND (which could be hardcoded, or better, an instance variable) in the time that has passed (dt) and adds that to its position.

    Hope that makes sense...

  • Ah. I remember now. Thank you for the information. =)

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