Attach momentum to elevator

This commit is contained in:
2020-06-01 05:32:07 -04:00
parent 1980139acb
commit 3dd00eabd3
5 changed files with 43 additions and 2 deletions

View File

@ -44,6 +44,8 @@ func start_moving(index):
func stop_moving():
emit_signal("elevator_stopped")
moving = false
motion = Vector2.ZERO
# Alert doors of updated elevator state
for door_path in doors:
get_node(door_path).on_elevator_stop(current_pos)
@ -54,6 +56,7 @@ func _physics_process(delta):
var target_pos = intial_pos + relative_positions[current_pos]
var angle = get_angle_to(target_pos)
var velocity = Vector2(cos(angle),sin(angle))
motion = velocity * elevator_speed
global_position += velocity * elevator_speed * delta
# Stop when elevator is at destination