48 lines
1.7 KiB
GDScript
48 lines
1.7 KiB
GDScript
class_name PickupDriftBehavior extends Resource
|
|
|
|
## Base resource that defines the global travel pattern of a pickup across
|
|
## the screen. Assign to [member drift_behavior] on a PickupBehaviorController.
|
|
|
|
enum DriftType {
|
|
STATIONARY, ## Does not move (aside from bob/shake).
|
|
SINE_WAVE, ## Travels in a sine curve.
|
|
LEAF_FALL, ## Drifts downward with gentle horizontal sway.
|
|
DIAGONAL, ## Moves diagonally in one direction.
|
|
}
|
|
|
|
@export_group("Drift")
|
|
## The drift pattern to apply.
|
|
@export var drift_type: DriftType = DriftType.STATIONARY
|
|
|
|
## Horizontal speed in pixels per second (applies to SINE_WAVE, LEAF_FALL).
|
|
@export var drift_speed: float = 30.0
|
|
## Vertical fall speed in pixels per second (applies to LEAF_FALL).
|
|
@export var fall_speed: float = 15.0
|
|
|
|
## Horizontal wave amplitude in pixels (applies to SINE_WAVE, LEAF_FALL).
|
|
@export var wave_amplitude: float = 40.0
|
|
## Wave frequency in cycles per second (applies to SINE_WAVE, LEAF_FALL).
|
|
@export var wave_frequency: float = 1.0
|
|
|
|
## Diagonal direction: +X forward, -X backward (applies to DIAGONAL).
|
|
@export var diagonal_forward: bool = true
|
|
|
|
## Main drift axis for SINE_WAVE and LEAF_FALL.
|
|
## true = horizontal travel (x), false = vertical travel (y).
|
|
@export var drift_along_x: bool = true
|
|
|
|
## Reverse the primary direction (left/right or up/down).
|
|
@export var reverse_direction: bool = false
|
|
|
|
## Randomize the perpendicular axis origin (y if horizontal, x if vertical).
|
|
@export var randomize_origin: bool = false
|
|
|
|
## Phase offset in radians — randomize per-instance for variety.
|
|
@export var phase_offset: float = 0.0
|
|
|
|
var _elapsed: float = 0.0
|
|
|
|
|
|
func start() -> void:
|
|
## Reset drift state when a new pickup is spawned.
|
|
_elapsed = 0.0
|