new item model and interactions
person can hold item now. Global can give item to person.
This commit is contained in:
@@ -1,15 +1,25 @@
|
||||
extends Node3D
|
||||
|
||||
@onready var outline_shader = preload("res://Shaders/outline.gdshader")
|
||||
|
||||
@onready var food_item = preload("res://Scenes/Prefabs/food_item.tscn")
|
||||
@export var debugLabel1: Label
|
||||
|
||||
signal interact(person,interact_object)
|
||||
|
||||
func _ready() -> void:
|
||||
print(outline_shader)
|
||||
|
||||
interact.connect(_on_interact)
|
||||
|
||||
func _on_interact(person, object):
|
||||
object.ActionNode.start_action(person, object)
|
||||
|
||||
|
||||
func give_item(person, item_id):
|
||||
var item = get_item_form_id(item_id)
|
||||
person.hold_item(item)
|
||||
|
||||
|
||||
|
||||
func get_item_form_id(id):
|
||||
match id:
|
||||
0:
|
||||
return food_item
|
||||
|
||||
@@ -14,6 +14,11 @@ var action: Interactable
|
||||
var is_target_reached: bool
|
||||
|
||||
var timer: Timer
|
||||
|
||||
var is_holding_item: bool = false
|
||||
var holdingItem: Object
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
nav_agent = $NavigationAgent3D
|
||||
meshI = $MeshInstance3D
|
||||
@@ -28,6 +33,8 @@ func _ready() -> void:
|
||||
is_in_action = false
|
||||
|
||||
timer = $Timer
|
||||
|
||||
Global.give_item(self, 0)
|
||||
#nav_agent.target_position = Vector3(-15.955,3.486,-58.942)
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
@@ -79,3 +86,14 @@ func _on_timer_timeout() -> void:
|
||||
if action != null:
|
||||
print("action stoped")
|
||||
action.stop_action(self,target_object)
|
||||
|
||||
|
||||
func hold_item(item):
|
||||
var newItem = item.instantiate()
|
||||
holdingItem = newItem
|
||||
newItem.position = Vector3(0,0.976, -0.065)
|
||||
self.add_child(newItem)
|
||||
|
||||
|
||||
func drop_item():
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user