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
@@ -5,6 +5,7 @@ extends NodeState
@export var wallCheck: ShapeCast2D
@export var floorCheck: RayCast2D
@export var ledgeGrabBox: CollisionShape2D
@export var fallState: NodeState
const jumpGravity = player.GRAVITY
@@ -14,13 +15,12 @@ const jumpGravity = player.GRAVITY
@onready var maxSpeed = player.maxSpeed
@onready var friction = player.friction
var currentJumpCount: int
var coyoteJump: bool
var currentJumpCount: int = 0
@warning_ignore("unused_parameter")
func _physics_process(delta: float) -> void:
await player.move
if player.is_on_floor() or (player.is_on_wall() and GameInputEvents.wall_cling_input()):
if player.is_on_floor():
currentJumpCount = 0
@warning_ignore("unused_parameter")
@@ -32,19 +32,18 @@ func on_phyisics_process(delta: float) -> void:
if player.is_on_floor():
currentJumpCount = 0
player.velocity.y = jumpHight
coyoteJump = false
fallState.coyoteJump = false
currentJumpCount += 1
if coyoteJump and currentJumpCount != maxJumpCount:
if fallState.coyoteJump and currentJumpCount <= maxJumpCount:
player.velocity.y = jumpHight
coyoteJump = false
fallState.coyoteJump = false
currentJumpCount += 1
#multi jumps
if !player.is_on_floor() and GameInputEvents.jump_input() and currentJumpCount != maxJumpCount:
player.velocity.y = jumpHight
currentJumpCount += 1
multiJump()
#movment shit under here
var direction: float = GameInputEvents.movement_input()
if direction:
@@ -64,11 +63,13 @@ func on_phyisics_process(delta: float) -> void:
func enter() -> void:
ledgeGrabBox.disabled = false
animatedSprite2D.play("Jump")
coyoteJump = true
if not fallState.coyoteJump:
currentJumpCount += 1
multiJump()
func exit() -> void:
ledgeGrabBox.disabled = true
coyoteJump = false
fallState.coyoteJump = false
animatedSprite2D.stop()
func transition_states() -> void:
@@ -84,3 +85,12 @@ func transition_states() -> void:
if wallCheck.is_colliding() and not floorCheck.is_colliding() and player.velocity.y == 0 and player.is_on_floor():
transition.emit("Grab")
if GameInputEvents.dash_input() and player.canDash:
transition.emit("dash")
func multiJump():
if !player.is_on_floor() and currentJumpCount <= maxJumpCount and Input.is_action_just_pressed("move_jump"):
player.velocity.y = jumpHight
currentJumpCount += 1