32 lines
873 B
GDScript
32 lines
873 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
|
|
|
|
func exit():
|
|
player.wallrun_timer = 0.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")
|
|
if 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
|