person can take and interact with item
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
extends CharacterBody3D
|
||||
|
||||
signal item_received
|
||||
|
||||
var nav_agent: NavigationAgent3D
|
||||
|
||||
var shirt_shader: ShaderMaterial
|
||||
@@ -19,7 +21,9 @@ var is_holding_item: bool = false
|
||||
var holdingItem: Object
|
||||
|
||||
|
||||
var target_item: int
|
||||
var target_item
|
||||
|
||||
var target_action: String
|
||||
|
||||
func _ready() -> void:
|
||||
nav_agent = $NavigationAgent3D
|
||||
@@ -35,6 +39,8 @@ func _ready() -> void:
|
||||
|
||||
timer = $Timer
|
||||
|
||||
|
||||
item_received.connect(_on_item_received)
|
||||
#nav_agent.target_position = Vector3(-15.955,3.486,-58.942)
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
@@ -46,6 +52,7 @@ func _physics_process(delta: float) -> void:
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("test"):
|
||||
target_action = "take"
|
||||
ItemManager.set_person_target_item(self, "food")
|
||||
#set_target_position()
|
||||
|
||||
@@ -67,16 +74,17 @@ func set_target(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
|
||||
var newPos = target_object.global_position
|
||||
newPos.y = self.position.y
|
||||
nav_agent.target_position = newPos
|
||||
print(target_object.ActionNode.can_be_used())
|
||||
print(target_object.can_be_used())
|
||||
|
||||
#nav_agent.target_position = start_pos
|
||||
|
||||
|
||||
func _on_navigation_agent_3d_target_reached() -> void:
|
||||
if target_object != null:
|
||||
print(22)
|
||||
is_target_reached = true
|
||||
nav_agent.target_position = self.global_position
|
||||
Global.interact.emit(self, target_object)
|
||||
@@ -90,11 +98,16 @@ func _on_timer_timeout() -> void:
|
||||
|
||||
|
||||
func hold_item(item):
|
||||
var newItem = item.instantiate()
|
||||
var newItem = item.duplicate()
|
||||
holdingItem = newItem
|
||||
newItem.position = Vector3(0,0.976, -0.065)
|
||||
self.add_child(newItem)
|
||||
|
||||
holdingItem.position = Vector3(0,0.976, -0.065)
|
||||
self.add_child(holdingItem)
|
||||
item_received.emit()
|
||||
|
||||
func drop_item():
|
||||
pass
|
||||
|
||||
|
||||
func _on_item_received():
|
||||
if holdingItem != null:
|
||||
holdingItem.use()
|
||||
|
||||
Reference in New Issue
Block a user