-
Notifications
You must be signed in to change notification settings - Fork 68
Description
Description
Advanced Back and Forth Movement
Advanced Back and Forth Movement is a Sprite behavior that moves a sprite back and forth on one axis, reversing after a set travel distance.
It supports optional start delay, pauses at each end, sprite flipping, animation synchronization, runtime control via actions, and per instance overrides via object variables.
Detailed documentation will be published on the GDevelop wiki once the extension is merged.
ScreenGrab.mp4
Typical uses
- Patrolling enemies and NPCs.
- Moving platforms.
- Simple sentry style motion with optional pauses at each end.
How to use the extension
Setup
Add the Advanced Back and Forth Movement behavior to a Sprite object, then configure:
- Activate movement
- Move speed (px/s)
- Travel distance (px)
- Movement orientation (horizontal or vertical)
- Initial direction (positive or negative)
- Movement start delay (s) (optional)
- Pause between direction reversals (s) (optional)
- Flip sprite on movement reverse (optional)
- Synchronize animation with movement (optional)
- Reset animation index on pause (optional, only relevant if animation sync is enabled)
Runtime control
You can change speed, distance, direction, pauses, delays, enabled state, sprite flipping, and animation synchronization at runtime via actions.
Per instance overrides (optional)
You can override behavior settings per instance using object variables.
Preferred variable structure:
__AdvancedBackAndForthMovement
Supported alias:
ABFM
If a child exists, it overrides the corresponding behavior setting for that instance. If it does not exist, the behavior default is used.
If both structures exist on the same instance, __AdvancedBackAndForthMovement takes precedence and ABFM is ignored.
Supported children
MoveSpeed(number): movement speed in pixels per second.MoveDistance(number): travel distance in pixels.MoveHorizontal(boolean): true for horizontal movement, false for vertical.StartPositive(boolean): true starts in the positive direction (right or down), false starts in the negative direction (left or up).StartDelay(number): start delay in seconds.PauseTime(number): pause duration at each end in seconds.Enabled(boolean): enables or disables movement for that instance.FlipSprite(boolean): enables or disables sprite flipping on direction reverse for that instance.SyncAnimation(boolean): enables or disables synchronizing animation state (paused/playing) with movement for that instance.AnimationReset(boolean): enables or disables resetting animation index to frame 0 when a pause begins for that instance, only relevant ifSyncAnimationis true.
Checklist
- I've followed all of the best practices.
- I confirm that this extension can be integrated to this GitHub repository, distributed and MIT licensed.
- I am aware that the extension may be updated by anyone, and do not need my explicit consent to do so.