-
Notifications
You must be signed in to change notification settings - Fork 0
Flying Enemy
The Flying Enemy is a dynamic enemy type that moves between two points in space, a predictable traversal pattern for the player. Unlike Patrol enemies, Flying Enemies are not constrained to ground navigation and instead move freely in straight-line paths between two defined offsets.
- Game Manager (handles reset / state transitions)
- Property Menu (modifies speed and movement offset)
- Entity Manager (spawning and saving enemies)
- Resource System (FlyingPreset .tres files)
Flying Enemies:
- Move between two points (Point A and Point B)
- Reverse direction when reaching either endpoint
- Use direct velocity-based movement (no pathfinding)
- Ignore gravity
- Can collide with level geometry
- Damage or kill player on contact (via base enemy logic)
- Can be stomped by player
- Player can defeat enemy by jumping on top of it
- Player takes damage on side collisions
- Supports health system
- Uses shared enemy interface (Enemy.gd)
- Moves in a straight line between two points:
- Point A = spawn position
- Point B = Point A + Offset
- Automatically switches direction when reaching a point
- Uses normalized direction vector for smooth motion
Controls how fast the enemy travels between points.
- Higher values = faster movement
Defines the second movement point relative to the spawn position.
- X controls horizontal distance
- Y controls vertical distance
- Supports diagonal movement
Example:
-
Offset (256, 0)-> moves right -
Offset (0, -256)-> moves up -
Offset (256, 256)-> moves diagonally
| Variable | Type | Description |
|---|---|---|
propertyFile |
Resource | Stores the currently assigned FlyingPreset resource |
point_a |
Vector2 | Spawn position (set when enemy is placed) |
point_b |
Vector2 | Calculated endpoint based on offset |
target_point |
Vector2 | Current movement destination |
speed |
float | Movement speed of the enemy |
Assigns a FlyingPreset resource to the enemy based on a generated ID.
Purpose:
- Loads the correct .tres file from disk
- Assigns it to propertyFile
- Sets the enemy's identity in the editor system
Applies a FlyingPreset resource to the enemy instance.
Purpose:
- Reads stored data from the resource
- Updates movement behavior based on saved values
- Recalculates patrol path (Point A and Point B)
Important:
- Does NOT reposition the enemy in world space
- Assumes enemy is already placed correctly by the editor
- Enemy spawns at Point A (editor placement)
- Point B is calculated using offset:
Point B = Point A + Offset - Enemy moves toward target point using normalized direction
- When close enough to target:
- Switches target to the opposite point
- Repeats indefinitely
- Editor places enemy
- assign_script()
- Resource created/saved (.tres)
- apply_script() on load
- Point A set = global position
- Point B calculated = A + offset
- Enemy begins patrol movement
Offset-based system was chosen instead of absolute coordinates to:
- Make enemy placement reusable
- Simplify editing in property menu
- Avoid dependency on world coordinates in resources
Movement is intentionally simple (no pathfinding) to ensure:
- Predictability for level design
- Easy debugging
- Low performance cost
- Very small offset values result in nearly invisible movement (must ensure slider range is sufficient)
- May stuck on props if approach at an unusual angle
The Flying Enemy is a simple but flexible enemy type designed for predictable linear movement. It is fully controlled through a resource-based system and integrates with the editor for real-time configuration.
Resources
Known Issues
Future Work
Globals
Managers
- Main Menu Manager
- Master Manager
- Camera Manager
- Hotkey Manager
- Import Export Manager
- Audio Manager
- Animation Manager
- PopUp Manager
UI
Managers
- Editor Manager
- Tile Manager
- Entity Manager
- Icon Manager
- Preview Manager
- Tool Manager
- Asset Manager
- Custom Cursor Manager
Tiles & Entities
- Grid Lines
- Preview Line
- Tiles & Entities
- Enemies
- Patrolling Enemy
- Flying Enemy
- Shooting Enemy
- Stationary Enemy
- Moving Platform
- Property Editing
Asset Swapping
UI
Managers
Player