Files
Papay-Shooter/movement/states/state_dash.gd
T
Hermes 6cac1f4032 fix: resolve GDScript parse errors in movement states
- state_dash.gd: Basis*Vector4 → Basis*Vector3 (no Vec4 in Godot 4.2)
- state_ground.gd: shape_owner_get_shape(0) → (0, 0); typed Variant vars; typed ray/normal
- state_slide.gd: same shape API fix + unique shape vars per branch
- state_wall_run.gd: split 'and' line into single typed bool expression
2026-06-02 23:15:20 -04:00

46 lines
1.3 KiB
GDScript

extends Node
class_name StateDash
var machine: MovementStateMachine
var params: MovementParams:
get: return machine.params
var elapsed: float = 0.0
var direction: Vector3 = Vector3.ZERO
var dash_cooldown_timer: float = 0.0
func enter(_data: Dictionary = {}) -> void:
elapsed = 0.0
dash_cooldown_timer = params.dash_cooldown
var input_v := machine.input_dir
var wish_dir := Vector3(input_v.x, 0.0, -input_v.y)
if wish_dir.length_squared() > 0.0:
direction = wish_dir.normalized()
else:
direction = -machine.player.global_transform.basis.z
direction.y = 0.0
direction = direction.normalized()
direction = (machine.player.global_transform.basis * Vector3(direction.x, 0.0, direction.y)).normalized()
machine.register_chain_mechanic("dash")
machine.player.velocity = direction * machine.get_effective_speed(params.dash_speed)
machine.on_ground = false
func exit() -> void:
pass
func update(delta: float) -> void:
elapsed += delta
dash_cooldown_timer -= delta
if elapsed > params.dash_duration:
machine.switch_to("air")
return
# Skip gravity, maintain dash velocity
machine.player.velocity = direction * machine.get_effective_speed(params.dash_speed)
machine.player.move_and_slide()
if machine.player.is_on_floor():
machine.on_ground = true
machine.switch_to("ground")