extends State class_name PlayerVault 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.direction_locked = true #player.cshape.shape = crouching_cshape #player.cshape.position.y = -74 player.ap.play("reverse vault") player.v_mult = player.vault_mult 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.z_index = 10 func exit(): player.direction_locked = false player.cshape.shape = standing_cshape player.cshape.position.y = -43 player.sprite.position.y = -48 player.v_mult = 1 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.z_index = 0 func update(delta): if player.wallcheckleft.is_colliding() or player.wallcheckright.is_colliding(): player.cshape.shape = crouching_cshape player.cshape.position.y = -66 player.sprite.position.y = -42 else: player.cshape.shape = standing_cshape player.cshape.position.y = -30 player.sprite.position.y = -44 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 func physics_update(delta): if not player.ap.is_playing(): Transitioned.emit(self, "PlayerFall")