Hello, i'm new to Godot and i'm trying to convert my work from unity over to Godot but I seem to be stuck on an issue with my inventory and toolbar system where the signal will not emit.
When I press 1 or 2 it will grab the item within my inventory and run Equip(), which works fine, but it doesnt seem to pass the signal. It seems to only pass the signal if I move this code into the _ready() function, which is not what I want.
I have connected the signal through the Node tab
ToolManager.gd
extends Node2D
func _on_Toolbar_player_swinging_tool(item_tool):
add_child(item_tool)
item_tool.global_position = position
ToolBar.gd:
extends Node2D
signal player_swinging_tool(tools)
var inventory = load("res://Player/Inventory.tres")
var myItem = null
export (int) var selectedTool = 0
export (int) var toolbarSize = 6
func NavigateToolBar():
if Input.is_action_just_pressed("NavigateLeft"):
if(selectedTool <= 0):
selectedTool = toolbarSize
else:
selectedTool -= 1
Equip()
if Input.is_action_just_pressed("NavigateRight"):
if(selectedTool >= toolbarSize):
selectedTool = 0
else:
selectedTool += 1
Equip()
myItem = inventory.items[selectedTool]
func Equip():
#Checking if item is a Tool
if myItem is ItemResource and myItem.type == myItem.ItemType.TOOLS:
var tools = myItem.Tool
var item_tool = tools.instance()
emit_signal("player_swinging_tool", item_tool)