GDevelop-extensions icon indicating copy to clipboard operation
GDevelop-extensions copied to clipboard

Enforce max speed (new extension)

Open tristanbob opened this issue 3 years ago • 4 comments

Limit the maximum speed an object will move from forces or from the physics behavior.

How to use:

  • Add the behavior that matches the method you use to move the object (forces or physics)
  • Set the maximum speed value in the behavior properties

Tips:

  • This only affects movement from forces or physics
  • This does not effect movement from other behaviors (platformer, top-down, draggable, etc)

Playable game

https://liluo.io/victrisgames/extension-enforce-max-speed

Project files

Extension - Enforce max speed.zip

Video

https://user-images.githubusercontent.com/8879811/194789391-1fe7f622-027c-4a6a-bd63-e805e236773b.mp4

tristanbob avatar Oct 10 '22 01:10 tristanbob

Errors were detected in this submission:

❌ 1 Error found in extension 'EnforceMaxSpeed':

  ⟶ ❌ (🔧) [Dots in sentences]: Field 'shortDescription' of the extension description misses a dot at the end of the sentence!


❌ 1 Error found in extensions - please fix it before generating the registry.

github-actions[bot] avatar Oct 10 '22 01:10 github-actions[bot]

I think I'm going to add a Minimum speed to this extension also. This way users can simply add acceleration and deceleration controls and let this extension handle the limits.

What should I call this extension, then? "SpeedRestrictions"

tristanbob avatar Oct 10 '22 15:10 tristanbob

I think I'm going to add a Minimum speed to this extension also. This way users can simply add acceleration and deceleration controls and let this extension handle the limits.

An object with a speed = 0 doesn't have any direction. It could make it difficult to do and I guess a minimum speed won't be very useful.

D8H avatar Oct 10 '22 18:10 D8H

I think I'm going to add a Minimum speed to this extension also. This way users can simply add acceleration and deceleration controls and let this extension handle the limits.

An object with a speed = 0 doesn't have any direction. It could make it difficult to do and I guess a minimum speed won't be very useful.

I would set up the minimum speed to only apply when the current speed is > 0 (it's the only way to know the direction).

I agree this is not going to be commonly used, but it could be useful in some cases. For instance, a weapon that pushes back enemies at different rates. The weapon could stop a small enemy, but the stronger ones would only be slowed (yes, this could be done in other ways).

It will only take me a minute to implement.

tristanbob avatar Oct 10 '22 22:10 tristanbob

It will only take me a minute to implement.

Oh, how silly I was. :)

I am not going to add MinimumSpeed to this PR, but perhaps I should change the name to SpeedRestrictions so that more restrictions could be added in the future?

tristanbob avatar Nov 01 '22 04:11 tristanbob

I renamed this to "Speed Restrictions" and added "Max rotation speed".

Playable game: https://liluo.io/victrisgames/extension-enforce-max-speed

Project files: Extension - Enforce max speed.zip

tristanbob avatar Nov 21 '22 02:11 tristanbob

I gave a quick look, it looks good. A max speed = 0 could be a valid use-case to stop the object.

D8H avatar Nov 21 '22 22:11 D8H

I gave a quick look, it looks good. A max speed = 0 could be a valid use-case to stop the object.

I agree, I removed that condition.

I used it as an optimization for when the user didn't set the max speed, but I think it's more important to have the flexibility you described.

tristanbob avatar Nov 22 '22 04:11 tristanbob