new item model and interactions

person can hold item now. Global can give item to person.
This commit is contained in:
Nikolai Fesenko
2025-08-18 01:33:54 +02:00
parent a62d2e29bc
commit 7ba255334d
16 changed files with 392 additions and 6 deletions

View File

@@ -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

View File

@@ -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