0 votes

I was watching an inventory system tutorial but came across a problem. I needed the slot to switch to a different style if there was an item in the panel (slot). Since the script was on every panel (slot), It ran all of them at the same time, resulting in all of them having the same style. How would I make them independent yet have the same script?

Godot version Latest Version
in Engine by (80 points)

1 Answer

0 votes

A naive approach could be to have an export variable that simply toggles a different style that you can change in the editor. Create different scenes for different inventory types with the configuration you desire or alternatively, have a base class and implement specialised inventories (or just write a different script).

Note that each instance of a script is independent of other instances; e.g. each panel you create will run its own _process and have its own variables - they aren't the same script.

by (826 points)

Ok! Thank you! :) I think I figured it out now.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.