24 lines
797 B
GDScript
24 lines
797 B
GDScript
extends PlayerState
|
|
class_name PlayerOnLadder
|
|
|
|
var climbing_started = false
|
|
|
|
func Enter():
|
|
climbing_started = false
|
|
|
|
func Physics_Update(delta):
|
|
character.global_position.x = lerp(character.global_position.x,character.current_ladder.global_position.x,delta * 8)
|
|
character.global_position.z = lerp(character.global_position.z,character.current_ladder.global_position.z,delta * 8)
|
|
|
|
ladder_movement(delta)
|
|
|
|
if !character.is_on_floor() and !climbing_started:
|
|
climbing_started = true
|
|
|
|
if character.is_on_floor() and climbing_started:
|
|
Transitioned.emit(self, "on foot")
|
|
|
|
func ladder_movement(delta):
|
|
var direction = Input.get_vector("move_down","move_up","move_left","move_right").x
|
|
character.velocity.y = lerp(character.velocity.y, direction * move_speed,delta * move_transition_speed)
|