Hi! I’m using the Rectangular Movement behavior in GDevelop. I want to control the movement speed of the object directly — not by changing the duration in the behavior settings, but by using a variable or event to adjust the actual speed (like pixels per second).
Is there any way to set or update the movement speed dynamically in events?
I’m not too familiar with the behavior. I see that it has a horizontal and vertical duration.
Distance divided by speed would give you the duration.
If distance was 100
Speed was 20 pixels per second
Then duration would be 5 seconds
100 divided by 20 is 5
It might be beneficial to add a suggestion as well for the ability to also set the speed instead of just duration. A speed action or property could do the math for the duration properties.
1 Like
That is a bit counter-intuitive… but I suppose it is convenient for making moving platforms.
You can get the height and width via expressions so to change the speed you can do this:
Horizontal duration set to Object.RectangleMovement::Width() / MySpeed
Vertical duration set to Object.RectangleMovement::Height() / MySpeed
1 Like
Thank you so much! It works