How can I exceed the Platform behaviors MaxSpeed?

0 favourites
  • 5 posts
From the Asset Store
Wanting to do a Shot n Run game easily? Here is your chance!
  • So, firstly I need to note I am not using the built-in Platform behavior of Construct2, rather I am using the "Platform2" behavior by Colludium, which has mostly the same actions and events, but includes collision filtering. This is going to factor into why I cannot use the Bullet behavior to accomplish my goal.

    So my game is a brawler (Think River City Ransom) and I want attacks to register knockback. i.e. I smack you with a club, your horizontal speed gets updated to move you backward.

    This almost works out-of-the-box, except for one issue, the knockback is limited to the object-being-knocked-back's MaxSpeed value. I.e. I smack you for 200 knockback speed, but your maxpeed value is set for a measly walking speed of 50, thus throttling that big smack to a measly whiff.

    There are a couple of obvious ideas that come to mind that I have tried so let me explain why they won't work:

    1. Update the MaxSpeed value on hits: This is a no-go. How do we know when to reset the MaxSpeed to walking speed? We could wait until the player stops or goes slower than the walking speed, but this takes control away from the player during these moments when they'd rather "lean in" to the momentum or push back against.

    2. Throw in the Bullet Behavior and update that instead: I tried this and it worked really beautifully until we collided with the Solid2 (Platform2 solids) objects, it clips through and once the bullet behavior stops moving, it traps the character in the solid or jumps them to the top.

    My last option is to run a check before the players Platform2 Control Input fires, to see if they are exceeding a "walkspeed" local variable. This would effectively be a secondary MaxSpeed value, and then I would set the MaxSpeed to an amount above what I expect the highest knockback value to be. In practice I am not happy with the results of this, so I'd love to hear other suggestions.

  • I would use option 1. It's the safest option, because mixing Platform with other behaviors or directly changing its position may cause different issues.

    Use Timer behavior to reset maximum speed after a knockback.

    Start a Timer for 0.3 seconds, set max speed to 200, apply vector. On Timer event set max speed back to 50.

  • I would use option 1. It's the safest option, because mixing Platform with other behaviors or directly changing its position may cause different issues.

    Use Timer behavior to reset maximum speed after a knockback.

    Start a Timer for 0.3 seconds, set max speed to 200, apply vector. On Timer event set max speed back to 50.

    I played with my bottom option a bit more and got it to work better, I have a "MaxWalkSpeed" variable that is checked against the platform objects speed, if the player is moving slower than the MaxWalkSpeed value, the input doesn't go off. This prevents the player from moving themselves faster than the walk speed, but lets me set the actual platform Max Speed to a much higher value.

    I haven't tested it as rigorously as I'd like though so I will keep your idea in mind in case this ends up having too many issues.

    I'm honestly a bit surprised this wasn't considered when the platform behavior was developed, SO many games hit players with forces that exceed the speeds of their characters movement, why there isn't a built in option to do that is beyond me.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • As a quick note for anyone that finds this post in the future, my attempt to set a secondary speed limit check before running the direction input with a variable didn't end well.

    This works fine when the player is on the ground, but if the player is in the air, the moment they hit the secondary speed limit they cease almost all horizontal movement, and drop like a stone.

    I guess this makes sense when you think about how momentum in the platformer object is applied when jumping, the moment you let go of the directional key your horizontal movement is cut drastically, and re-pressing it before you land doesnt net you the same horizontal movement bonus.

    Cut your losses and update the Max Speed value :/ it's not elegant, but it will of course work.

  • Hi there. I recommend either Option 1 or you could disable Platform2 and use events to make the knock-back effect.

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