I'm working on a Megaman-like wall sliding where the player slides down the wall.
The player must be in aerial state first before they go to wall state.
The problem is that when it touches the wall, it just... stuck. I have to press the jump button to change into aerial state and unstuck it.
#Aerial.gd
func physics_update(delta: float) -> void:
player.get_input_direction()
player.calculate_velocity()
player.apply_gravity(delta)
if Input.is_action_just_pressed("jump") and player.can_double_jump:
player.velocity.y = -player.jump_force
player.can_double_jump = false
if Input.is_action_just_released("jump") and player.velocity.y < 0:
player.velocity.y *= 0.25
player.apply_movement()
if player.is_on_floor():
if is_equal_approx(player.velocity.x, 0.0):
state_machine.transition_to("Idle")
else:
state_machine.transition_to("Moving")
else:
if Input.is_action_just_pressed("dash") and player.can_dash:
state_machine.transition_to("Dashing")
elif player.is_on_wall():
state_machine.transition_to("Wall")
#Wall.gd
func physics_update(delta: float) -> void:
player.velocity.y += player.wall_gravity * delta
if Input.is_action_just_pressed("jump"):
state_machine.transition_to("Aerial")
if player.is_on_floor():
state_machine.transition_to("Idle")