New actions: Gradually decreasing forces (impulses)

Brief description

Actions to apply progressively decreasing forces (“impulses”?) for objects once, not related or tied to the Physics engine. This is useful for speed boosts, dashes and more (see below).

More detailed explanation

For multiple game types and mechanics, just using simple forces is not enough to smoothly make the element work. Speed boosts look bad and very sharp when they end abruptly and therefore make recovering from those speed boost as well as predicting the resulting velocity of the object difficult for the player and feels unnatural.

I’m sorry if the words “force” and “impulse” are not accurate here or if I didn’t use them correctly but I still need to express a difference between those “types” of forces.

Why?

Trying to figure out a way to make a speed boost panel or dashes for a project, I couldn’t find a way to properly set up a separate trigger that would take the force away and do it in a smooth way so the player doesn’t abruptly half his velocity after the speed boost ended. An automatically and gradually decreasing force would not only make programming elements like this easier but the result would look more realistic as well and makes predicting the force and the velocity easier for the user.

Main problem with workarounds

Current tools like Tween::Ease() (expression), the Tween behavior or simply changing the length/strength value is not possible since there are no actions to do so and also the forces can’t be differentiated or specified individually.


Visualization using different approaches

See images below

  • Permanent force has to be started but most importantly stopped manually via events. It’s likely, that the events or conditions that remove that permanent force again change depending on location, gravity (different time duration etc.) and others.
    Contra → When the forces are removed, the object stops immediately

  • Instant force works but it requires a lot of events to make the logic work and look somewhat smooth. This also need many calculations for what the force difference is, how much is left, then the increasing/decreasing of a variable for counting and decreasing the force length/strength and so on.
    Contra → Needs manually applying a new instant force every frame until it should be “faded out”

  • [New force type/action(s) that would be incredible to have]
    Impulse (decreasing force) is triggered/applied once and then gradually falls back to zero. Ideally, the duration time[sec] for the force is a argument in the action to also control the speed of it.


Useful applications

Adding this as actions would make handling, programming and using, to name a few, the following elements/mechanics significantly easier and smoother:

  • Trampolines (Platformer)
  • Boost panels (Top-Down, Platformer)
  • Dashes (Top-Down, Platformer)
  • Impacts e.g. for golf, tennis (Top-Down, Platformer)
  • Bounce pads (Top-Down, Platformer)

About workarounds

Even if there should be a decent workaround for this, I still believe this would be a great feature to have and would definitely make programming elements from the list above easier and creates a smoother result as well.

3 Likes

Just to check, but couldn’t you do a gradually decreasing force by using a tweened object variable as the force value?

Basically:
Event 1: Start tween in an event.
Event 2: Use the If tween is running condition to apply the force.
The event action would be to apply the force, with the force value being based off the object variable’s value.

Hmm, I see. I don’t fully know how to put it but with all the options now available with Tween and the “Tween::Easing()” expression and even “wait x seconds”, this workaround (which seems to be the best workaround for it) still feels like a workaround and not a “solid solution” - not saying that Tweens aren’t a solid solution.

Of course, my main reason to open this request is to make stuff like this easier to add, control and adjust in a clear, clean and simple way. Another reason is that this would both enable newer users to just use it right away (like the “wait x seconds”) without having to learn Tweens and all that comes with it and therefore doesn’t require a force to have a Tween-object, if you get my point.

I really appreciate your comment/workaround, this should definitely work just fine, I’m not questioning it and I don’t know how I should describe it but I’m having a strange feeling about tying Tweens and forces together, creating more work and maybe even limiting possibilities due to the dependencies :thinking:

No worries, I follow your line of thought.

Although, to be clear, it would really only be one unique action and one unique condition to do this with tweens. (Unique as in wouldn’t be required with any other logic method of doing a dash, for example).

Here’s a super quick example:


https://game-previews.gdevelop-app.com/1653664691515-208806/index.html

And I think learning about using tweens would be a net positive, especially since this is such an easy example that it could help people learn tweens in general.

Again, not saying anything against this suggestion, just showing the simplicity of this one.

1 Like

Yes, that’s fair. Alright, will take that back - learning Tweens is not the worst idea.
I was just concerned if implementing a full Tween behavior is a bit overkill for what it’s ultimately used for but actually thinking about it I don’t know where that concern came from since, well, that’s the purpose of Tweens. Also, now with you tying the Tween behavior directly to the object itself (for some unknown reason I didn’t think about that and probably would’ve done that with a helper object) the example you made looks really clean!

Thank you again for the example, I will experiment with it a bit more but I think I will use it for my project as well.

1 Like

I think this feature used to exist, I recall a thing where you could specify a multiplier to apply to the force intensity over each frame until it reaches 0. Instant/permanent were just suggestions for 0 and 1, since multiplying by 0 ends the force on the same frame, and multiplying by 1 makes it go on forever since it doesn’t change anything. That also allowed to make not only slowly decreasing forces but slowly increasing ones too.

Huh, that’s very interesting. Do you happen to know what happened to it, why it was removed?

No idea :person_shrugging: Maybe 4ian thought it wasn’t user-friendly enough? Or maybe I just dreamed that up.