Skip to content

Moving Platform

NebSeniah edited this page Jul 17, 2026 · 7 revisions

Moving Platform

System Summary

The moving platform is an entity that works similarly to the flying enemy, except it also includes a progress property and gets landed on by the player as opposed to being killed or dealing damage.


Connected Systems

Connecting Systems:

Subsystems:

  • None

Bugs

List of known bugs. Be descriptive but keep it brief!

  • Small amount of jitter once it changes direction

Feature List / Breakdown of Features

Moving Platform Entity:

  • Flying Speed: Controls how fast the moving platform travels between points. Higher values = faster movement.
  • Point B Offset: Defines the second movement point relative to the spawn position. X controls horizontal distance, Y controls vertical distance. Supports diagonal movement (e.g., Offset (256, 0) -> moves right, Offset (0, -256) -> moves up, Offset (256, 256) -> moves diagonally).
  • Moves in a straight line between Point A (spawn position) and Point B (Point A + Offset).
  • Automatically switches direction when reaching a point.
  • Uses normalized direction vector for smooth motion.
  • Uses direct velocity-based movement (no pathfinding).
  • Ignores gravity.
  • Can't collide with level geometry.
  • Other entities can stand on it.

Important Variables

propertyFile: Resource = Stores the currently assigned MovingPlatform resource.

pointA: Vector2 = Spawn position (set when platform is placed).

pointB: Vector2 = Calculated endpoint based on offset.

targetPoint: Vector2 = Current movement destination.

speed: float = Movement speed of the platform.

progress: float = Starting progress of the moving platform

easing : bool = If true, the platform slows down when close to either endpoint.

visiblePath: bool = If true, the platform's path line is visible to the player in play mode.

momentumShare: bool = If true, the platform's velocity gets shared with the player when they move off of it.

**delay: float = The delay, in seconds, that the platform has before it starts moving after hitting a target point

**alwaysActive: bool = When on, the platform starts moving before being on screen. Makes it easy to line up platforms.


Important Functions

  • func assign_script(id: String, position: Vector2i) -> void: Assigns a MovingPlatform resource to the entity based on a generated ID. Loads the correct .tres file from disk, assigns it to propertyFile, and sets the entity's identity in the editor system.

  • func apply_script(file: Resource) -> void: Applies a MovingPlatform resource to the entity instance. Reads stored data from the resource, updates movement behavior based on saved values, and recalculates patrol path (Point A and Point B). Does NOT reposition the entity in world space; assumes enemy is already placed correctly by the editor.


Movement Logic

  1. Platform spawns at Point A (editor placement)
  2. Point B is calculated using offset: Point B = Point A + Offset
  3. Platform moves toward target point using normalized direction
  4. When close enough to target: switches target to the opposite point and repeats

Data Flow

  1. Editor places platform
  2. assign_script()
  3. Resource created/saved (.tres)
  4. apply_script() on load
  5. Point A set = global position
  6. Point B calculated = A + offset
  7. Platform begins patrol movement

Future Work / Risks

Future Work:

  1. Add support for variable movement patterns (e.g., sine wave, circular)

Risks:

  • None

Miscellaneous Notes

  • None

Clone this wiki locally