33 lines
994 B
GDScript
33 lines
994 B
GDScript
extends State
|
|
class_name PlayerCrouchWalk
|
|
|
|
var crouching_cshape = preload("res://resources/player crouching cshape.tres")
|
|
var standing_cshape = preload("res://resources/player standing cshape.tres")
|
|
|
|
func get_state_name():
|
|
return str(self).split(":")[0]
|
|
|
|
func enter():
|
|
player.cshape.shape = crouching_cshape
|
|
player.cshape.position.y = -31
|
|
player.v_mult = player.crouch_mult
|
|
func exit():
|
|
player.cshape.shape = standing_cshape
|
|
player.cshape.position.y = -44
|
|
player.v_mult = 1
|
|
func update(delta):
|
|
player.ap.play("crouch walk")
|
|
|
|
if player.head_clear() and (Input.is_action_just_released("crouch") or !Input.is_action_pressed("crouch")):
|
|
Transitioned.emit(self, "PlayerIdle")
|
|
player.stuck_under_object = false
|
|
elif Input.get_axis("move_left", "move_right") == 0:
|
|
Transitioned.emit(self, "PlayerCrouch")
|
|
elif !player.head_clear():
|
|
if player.stuck_under_object != true:
|
|
player.stuck_under_object = true
|
|
print("player stuck under object")
|
|
|
|
func physics_update(delta):
|
|
pass
|