Files
sidescroller-project/sidescroller/scripts/playerwallrun.gd

37 lines
1015 B
GDScript

extends State
class_name PlayerWallrun
func get_state_name():
return str(self).split(":")[0]
func enter():
player.wallrun_available = false
player.velocity.x = 2000 * player.facing_direction # An Wand haften
player.ap.play("wallrun")
player.sprite.position.x = player.facing_direction * -10
func exit():
player.wallrun_timer = 0.0
player.sprite.position.x = 0
player.velocity.y = 0
func update(delta):
pass
func physics_update(delta):
player.wallrun_timer += delta
player.velocity.y = player.wallrun_speed # Bewegt nach oben
if player.facing_direction > 0 && !player.wallrun_raycast_right2.is_colliding():
Transitioned.emit(self, "PlayerFall")
elif player.facing_direction < 1 && !player.wallrun_raycast_left2.is_colliding():
Transitioned.emit(self, "PlayerFall")
elif player.wallrun_timer >= player.wallrun_time:
Transitioned.emit(self, "PlayerWallrunPushoff")
func transitionwallrunpushoff() -> bool:
var result = player.wallrun_timer >= player.wallrun_time
return result