Fixed player double jumps not working. and added a dash

This commit is contained in:
2026-02-12 06:56:01 -05:00
parent 83a4a8f374
commit 5518f3ce79
12 changed files with 129 additions and 108 deletions
@@ -0,0 +1,50 @@
extends NodeState
@export var player: Player
@export var animatedSprite2D: AnimatedSprite2D
const jumpGravity = player.GRAVITY
var dashSpeed: float = 500
var dashTime: float = .3
var dashDone: bool = false
var canDash: bool = true
@warning_ignore("unused_parameter")
func on_process(delta: float) -> void:
pass
@warning_ignore("unused_parameter")
func on_phyisics_process(delta: float) -> void:
player.velocity.y += jumpGravity * delta
var direction = -1 if animatedSprite2D.flip_h else 1
if direction:
player.velocity.x =+ dashSpeed * direction
transition_states()
func enter() -> void:
player.canDash = false
dashDone = false
animatedSprite2D.play("Fall")
await get_tree().create_timer(dashTime).timeout
dashDone = true
func exit() -> void:
animatedSprite2D.stop()
func transition_states() -> void:
if not dashDone:
return
if player.is_on_floor():
transition.emit("idle")
if not player.is_on_floor():
transition.emit("fall")