Use Autoload or signal?

I have a question i want to create a equipItem System on Player
should i create a signal that when i click on hotbar and in that slot have item so signal have item emit or if i click on hotbar but no item emit signal no item

Or i just use Autoload Global.script that have var equipItem == null and then change it depend on slot that i click have item or not

sorry if my gramma is not correct

How you organize your project usually depends on the project itself, but personally I would choose the ‘signals’ version, that’s probably more scalable and you can always have an autoload as a manager that listens this signals.

thanks you

Use signals to keep your components decoupled and the game logic better maintainable. Autoload classes are better suited to keep the global game state.

1 Like

Signals are used when you want to execute a function in response to a certain event.

In case the nodes in your scenes don’t directory talk to one another (maybe you’re instantiating through code instead of them already being present in the editor), an autoload signal might be better.

1 Like