Small Problem With A Tutorial

You have there two scripts. One on the CanvasLayer and one on the Inventory.
We are talking about the one on the Inventory?
And you switch the visibility of the Inventory itself?
I guess you want to switch the visibility of the Container instead of just the Inventory?

1 Like

The inventory has this script:

extends Control
@onready var isopen: bool = false



var items_to_load := [
	"res://InventoryItems/MINILSTICKER2D.tres",
	"res://InventoryItems/VhsTapeInv.tres"
]

func _ready():
	for i in 24:
		var slot := InventorySlot.new()
		slot.init(item_data.Type.MAIN, Vector2 (32, 32))
		%Grid.add_child(slot)
	for i in items_to_load.size():
		var item = InventoryItem.new()
		item.init(load(items_to_load[i]))
		%Grid.get_child(i).add_child(item)
		
	

The canvas layer is the one with the open and close script

The inventory just isnt showing up when i try to click I, its only the canvas layer and the panel/container

Could you show the content of the Inventory scene, too, please?
The Inventory scene will run by itself? (F6 with the inventory scene active)

1 Like

It will run by itself ^^

Ok, and the node tree of this scene, please.
Do you have changed the “process” of the scene node? Default is “inherit”.
So far it looks ok to me.
Could you pause your game with open Inventory, and check the scene tree with “remote”. There you can see the real scene tree at runtime. There the nodes of the inventory are visible?

1 Like

sorry it took so long to respond!! Here ya go:

How do i get to remote? I paused the game with an open inventory but i cant figure out how to check the scene tree

You need to run the game in order to access the “remote” tab. This is because the remote tab reflects the node tree on runtime, which can be different than the saved files.

When you run your game and than pause it (F7), you get an additional “remote” button.
If you press this one, you can see the scene tree at runtime. There take a look if the Inventory is visible and running. Sorry, I get the problem, but I have no idea why it’s happening.

ooooooh okay! the inventory doesnt show up when its open and i go to remote

omg wait i go it! I had to parent the inventory to the canvas layer! :DDDDDDDDDDDD

Alrighty I only need help with three more things (hopefully)

It spawns in visible, how would I make that not happen?

I think this might be an on area entered kind of thing, but I don’t know if this is technically entering?

I’ve got it so that you can click and drag them, but I want to be able to drag and drop the items to items within the world to cause an interaction with both of them, like those old flash escape room games?

I also don’t know if being able to click and drag the 2d sprites is just a thing of windows, since you can also do that kind of stuff on google, I don’t know if I coded it to do that or not. I remember in the tutorial he put some code in for clicking and dragging, but I didn’t do the ‘drag and drop to add stats in the main slots to your player’ script, since my game doesn’t have stats like that.

And also, I have an interactable object script:

extends Node3D

var current_interactions := []
var can_interact := true


func _input(event: InputEvent) -> void:
		if event.is_action_pressed("interact") and can_interact:
			if current_interactions:
				can_interact = false
			
				await current_interactions[0].interact.call()
			
				can_interact = true



func _process(_delta: float) -> void:
		if current_interactions and can_interact:
			current_interactions.sort_custom(_sort_by_nearest)
		
	
func _sort_by_nearest(area1, area2):
	var area1_dist = global_position.distance_to(area1.global_position)
	var area2_dist = global_position.distance_to(area2.global_position)
	return area1_dist < area2_dist
	
func _on_area_3d_area_entered(area: Area3D) -> void:
	current_interactions.push_back(area)


func _on_area_3d_area_exited(area: Area3D) -> void:
	current_interactions.erase(area)
		

and I want to make it so that when you interact with an object, it goes into your inventory. How would I do that with this script?