Platform: is accelerating/decelerating event?

0 favourites
  • 3 posts
From the Asset Store
Very simple code without excess options (15 events for server and 11 events for client)
  • What would be the best way to monitor if a player is accelerating or decelerating? Basically, something equivalent to the "is jumping/is falling" events but horizontally (for walking & running)?

    I know there is the "compare speed" Platform event. Would I just set that to run globally every tick and compare to the last tick? Seems like that would work but probably not be the most processing-efficient way to do it.

    Thanks in advance for any help.

  • Well, if no physics are used, you could basically monitor if keys are not held down + if the player is not jumping/falling (if you care about vertical speed too) - if both are true, then the player is not accelerating. Without external factors that affect the speed, this would be accurate until the moment when the player reaches the maximum speed (e.g. moving at the maximum velocity, which is constant), perhaps adding a "is speed < maximum speed" check could prevent this.

    However, these checks probably would be less efficient than just updating a single variable (e.g. "PreviousTickSpeed").

    Then again, none of this should be too important, as drawing processes usually take up most of the CPU / GPU resources (usage commonly said to be around ~90%).

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • (sorry for the "test"; I'm having login issues that erase my posts!)

    Thanks for the quick reply and sorry for the slow one on my end. Your suggestion worked perfectly. I have an IsAccelerating and IsDecelerating variable that are set by a PreviousTickSpeed variable and it all works :)

    Also, that's great to hear that drawing is 90% of the resources. I've made a lot of game-spec art so I'm not worried about that but I don't know much about optimizing routines and such. Good to know it's more forgiving.

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