66 lines
2.1 KiB
GDScript
66 lines
2.1 KiB
GDScript
extends State
|
|
class_name PlayerClimbUp
|
|
|
|
func get_state_name():
|
|
return str(self).split(":")[0]
|
|
|
|
var ledge_cshape = preload("res://resources/player ledge cshape.tres")
|
|
var standing_cshape = preload("res://resources/player standing cshape.tres")
|
|
|
|
func enter():
|
|
|
|
player.ap.play("climb up")
|
|
player.ap.playback_process_mode = AnimationPlayer.ANIMATION_PROCESS_MANUAL #rootmotion
|
|
var root_node := player.get_node("RootMotion") #rootmotion
|
|
|
|
player.rootmotion_prev = root_node.position #rootmotion
|
|
|
|
player.sprite.position.x = player.facing_direction * 11
|
|
player.sprite.position.y = -60
|
|
|
|
player.cshape.shape = ledge_cshape
|
|
player.cshape.position.y = -69
|
|
|
|
player.z_index = 10
|
|
|
|
func exit():
|
|
player.ap.playback_process_mode = AnimationPlayer.ANIMATION_PROCESS_IDLE #rootmotion
|
|
player.RootMotion.position = Vector2(11, -60) #rootmotion
|
|
player.rootmotion_prev = Vector2(11, -60) #rootmotion
|
|
|
|
player.sprite.position.x = 0
|
|
player.sprite.position.y = -48
|
|
|
|
player.cshape.shape = standing_cshape
|
|
player.cshape.position.y = -43
|
|
|
|
player.z_index = 0
|
|
|
|
func update(delta):
|
|
pass
|
|
|
|
func physics_update(delta):
|
|
|
|
player.jumpbuffer(delta)
|
|
|
|
player.ap.advance(delta)
|
|
|
|
var current_root_pos = player.RootMotion.position #rootmotion
|
|
var root_delta = current_root_pos - player.rootmotion_prev #rootmotion
|
|
|
|
player.position += Vector2(root_delta.x * player.facing_direction, root_delta.y)
|
|
player.rootmotion_prev = current_root_pos #rootmotion
|
|
|
|
if not player.ap.is_playing():
|
|
Transitioned.emit(self, "PlayerFall")
|
|
|
|
#ursprüngliches manuelles bewegen des players während dem Climb up:
|
|
#if player.position != player.climbup_pos1 && !player.climbup_pos1_reached:
|
|
#player.position = player.position.move_toward(player.climbup_pos1, player.climbup_speed_y * delta)
|
|
#if player.position == player.climbup_pos1:
|
|
#player.climbup_pos1_reached = true
|
|
#elif player.position != player.climbup_pos2 && player.climbup_pos1_reached:
|
|
#player.position = player.position.move_toward(player.climbup_pos2, player.climbup_speed_x * delta)
|
|
#elif player.position == player.climbup_pos2:
|
|
#Transitioned.emit(self, "PlayerFall")
|