person interaction update
This commit is contained in:
@@ -8,6 +8,12 @@ var meshI: MeshInstance3D
|
||||
var start_pos: Vector3
|
||||
var target_object: Node3D
|
||||
|
||||
var is_in_action: bool
|
||||
var action: Interactable
|
||||
|
||||
var is_target_reached: bool
|
||||
|
||||
var timer: Timer
|
||||
func _ready() -> void:
|
||||
nav_agent = $NavigationAgent3D
|
||||
meshI = $MeshInstance3D
|
||||
@@ -19,11 +25,15 @@ func _ready() -> void:
|
||||
|
||||
start_pos = global_position
|
||||
|
||||
is_in_action = false
|
||||
|
||||
timer = $Timer
|
||||
#nav_agent.target_position = Vector3(-15.955,3.486,-58.942)
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
var new_velocity = global_position.direction_to(nav_agent.get_next_path_position()) * 5.0
|
||||
look_at(nav_agent.target_position)
|
||||
if !is_target_reached:
|
||||
look_at(nav_agent.target_position)
|
||||
velocity = new_velocity
|
||||
move_and_slide()
|
||||
|
||||
@@ -42,19 +52,30 @@ func set_random_shirt():
|
||||
|
||||
|
||||
func set_target(object):
|
||||
target_object = object
|
||||
|
||||
#if !is_in_action and object.ActionNode.can_be_used():
|
||||
if !is_in_action:
|
||||
target_object = object
|
||||
#nav_agent.target_position = target_object.ActionNode.global_position
|
||||
func set_target_position():
|
||||
is_target_reached = false
|
||||
var newPos = target_object.ActionNode.global_position
|
||||
newPos.y = self.position.y
|
||||
nav_agent.target_position = newPos
|
||||
|
||||
print(target_object.ActionNode.can_be_used())
|
||||
|
||||
#nav_agent.target_position = start_pos
|
||||
|
||||
|
||||
func _on_navigation_agent_3d_target_reached() -> void:
|
||||
if target_object != null:
|
||||
is_target_reached = true
|
||||
nav_agent.target_position = self.global_position
|
||||
Global.interact.emit(self, target_object)
|
||||
pass
|
||||
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
if action != null:
|
||||
print("action stoped")
|
||||
action.stop_action(self,target_object)
|
||||
|
||||
Reference in New Issue
Block a user