added user action
This commit is contained in:
@@ -6,18 +6,19 @@ var shirt_shader: ShaderMaterial
|
||||
var meshI: MeshInstance3D
|
||||
|
||||
var start_pos: Vector3
|
||||
|
||||
var target_object: Node3D
|
||||
|
||||
func _ready() -> void:
|
||||
nav_agent = $NavigationAgent3D
|
||||
meshI = $MeshInstance3D
|
||||
shirt_shader = meshI.get_surface_override_material(1)
|
||||
|
||||
BuildManager.object_placed.connect(_on_object_placed)
|
||||
BuildManager.object_added.connect(_on_object_added)
|
||||
|
||||
set_random_shirt()
|
||||
|
||||
start_pos = global_position
|
||||
|
||||
#nav_agent.target_position = Vector3(-15.955,3.486,-58.942)
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
@@ -26,10 +27,12 @@ func _physics_process(delta: float) -> void:
|
||||
velocity = new_velocity
|
||||
move_and_slide()
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("test"):
|
||||
set_target_position()
|
||||
|
||||
|
||||
func _on_object_placed(build_position):
|
||||
nav_agent.target_position = Vector3(-14.305,3.486,-59.836)
|
||||
func _on_object_added(object):
|
||||
set_target(object)
|
||||
|
||||
|
||||
func set_random_shirt():
|
||||
@@ -38,5 +41,19 @@ func set_random_shirt():
|
||||
pass
|
||||
|
||||
|
||||
func _on_navigation_agent_3d_navigation_finished() -> void:
|
||||
nav_agent.target_position = start_pos
|
||||
func set_target(object):
|
||||
target_object = object
|
||||
#nav_agent.target_position = target_object.ActionNode.global_position
|
||||
func set_target_position():
|
||||
var newPos = target_object.ActionNode.global_position
|
||||
newPos.y = self.position.y
|
||||
nav_agent.target_position = newPos
|
||||
|
||||
|
||||
#nav_agent.target_position = start_pos
|
||||
|
||||
|
||||
func _on_navigation_agent_3d_target_reached() -> void:
|
||||
if target_object != null:
|
||||
Global.interact.emit(self, target_object.ActionNode)
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user