Move some movement logic from PathNavigator to NPC
This commit is contained in:
parent
5f4bb0ffa4
commit
872280d31f
@ -3,6 +3,7 @@ class_name NPC
|
||||
|
||||
|
||||
export(float) var turn_speed = 2.5
|
||||
export(float) var speed = 8
|
||||
|
||||
var current_target
|
||||
var current_look_target
|
||||
@ -20,6 +21,13 @@ func _process(delta):
|
||||
|
||||
if diff.length() > 0.1:
|
||||
look_at(transform.origin + target, Vector3.UP)
|
||||
|
||||
if current_target:
|
||||
# Move towards the current goal
|
||||
var direction_normalized: Vector3 = (current_target - transform.origin).normalized()
|
||||
|
||||
look_towards(direction_normalized)
|
||||
move_towards(direction_normalized * speed)
|
||||
|
||||
|
||||
func set_position(position: Vector3):
|
||||
|
@ -7,7 +7,6 @@ var _current_path_index
|
||||
|
||||
var _arrived_distance_threshold = 0.1
|
||||
|
||||
export(float) var speed = 8
|
||||
export(NodePath) var body_nodepath
|
||||
|
||||
var navigation: Navigation
|
||||
@ -48,7 +47,7 @@ func _process(delta):
|
||||
var direction_normalized: Vector3 = (current_goal - _get_body_position()).normalized()
|
||||
|
||||
body.look_towards(direction_normalized)
|
||||
body.move_towards(direction_normalized * speed)
|
||||
body.move_towards(direction_normalized * body.speed)
|
||||
|
||||
|
||||
# Returns the point we should currently be moving towards
|
||||
|
Loading…
x
Reference in New Issue
Block a user