Fixed player double jumps not working. and added a dash
This commit is contained in:
@@ -5,6 +5,7 @@ extends NodeState
|
||||
@export var wallCheck: ShapeCast2D
|
||||
@export var floorCheck: RayCast2D
|
||||
@export var ledgeGrabBox: CollisionShape2D
|
||||
@export var jumpState: NodeState
|
||||
|
||||
|
||||
@export_category("Fall State")
|
||||
@@ -16,15 +17,12 @@ const GRAVITY = player.GRAVITY
|
||||
@onready var maxSpeed = player.maxSpeed
|
||||
@onready var friction = player.airFriction
|
||||
|
||||
var fallTimeAmount: int = 10
|
||||
var fallTime: float
|
||||
|
||||
@warning_ignore("unused_parameter")
|
||||
func on_process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
func on_phyisics_process(delta: float) -> void:
|
||||
fallTime += fallTimeAmount * delta
|
||||
#print(fallTime)
|
||||
if !player.is_on_floor():
|
||||
get_coyte_time()
|
||||
@@ -52,7 +50,6 @@ func get_coyte_time() -> void:
|
||||
|
||||
func enter() -> void:
|
||||
animatedSprite2D.play("Fall")
|
||||
fallTime = 0
|
||||
ledgeGrabBox.disabled = false
|
||||
if player.is_on_floor():
|
||||
ledgeGrabBox.disabled = true
|
||||
@@ -60,29 +57,24 @@ func enter() -> void:
|
||||
coyoteJump = true
|
||||
|
||||
func exit() -> void:
|
||||
fallTime = 0
|
||||
ledgeGrabBox.disabled = true
|
||||
animatedSprite2D.stop()
|
||||
|
||||
func transition_states() -> void:
|
||||
#transitioning state
|
||||
|
||||
#idle state
|
||||
if player.is_on_floor() and fallTime > 5:
|
||||
transition.emit("Land")
|
||||
|
||||
elif player.is_on_floor() and fallTime <= 5:
|
||||
if player.is_on_floor():
|
||||
transition.emit("idle")
|
||||
|
||||
#jump state
|
||||
if GameInputEvents.jump_input():
|
||||
transition.emit("jump")
|
||||
|
||||
#jump state
|
||||
if GameInputEvents.jump_input() and coyoteJump:
|
||||
transition.emit("jump")
|
||||
|
||||
if wallCheck.is_colliding() and !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")
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user