Hello, I made a hotbar inventory system based on hotkeys (1, 2, and 3) that I press to equip whatever Item from my inventory that I have picked up using nodes like Spawn Actor and Destroy Actor.
I have a base master actor class with a few actor blueprints inheriting from it which are items I can pick up, each of these actor bps contain their respective struct variable which has info like Enum, class, name… some of these items need to have some functionality like the flashlight for example which needs to be turned on and off by right clicking.
When I enable the input inside the master actor blueprint, and have the logic to turn on and off the flashlight on its actor blueprint, I can then press right click whenever I want and turn on and off the flashlight from afar without even interacting with it…
Is there a way I can enable the input only when an actor blueprint is attached, and disable the input when the actor is not in use (still in inventory)? Thank you in advance.
Hello! im also new so my answer will be really basic
2 think roads:
branch with the condition at begening? IsAttached(1.2.3)-> enableInputON/OFF
i dont do anything but last night journey took me to magic node called BIND - there’s a tutorial with somebody explaining this as a “Observator” “subscribe” to for example destroy something and diffrent things can act diffrent to that particular event
Hi! I thought about the first one but I think it’ll be a mess the more items exist in the world, and it’ll be a bit performance intensive I guess? since it’ll have to check which item is equipped one by one.
As per the second one, I assume you’re talking about Event Dispatchers? I haven’t learnt them yet but I think they may actually be what I need, I’ll just have to learn it now and try.
Thanks! If anyone else has different options, I’ll be glad to hear about them.
I managed to solve this simply by casting to the target actor’s bp, so now, even when there are 10 copies of the actor, only the target actor will have logic applied to it. I think it’s less modular this way as I will have to do multiple branches or whatnot when I have multiple items with their functionalities. Best way would be to have a OnItemActionTriggered function inside your base item class, all items should inherit from it and have whatever should happen when the input is pressed, communication should be through the same interface used to pick up the item, it makes sense as it all relates to the item.
Thanks! In the Enum list, that’s the == equal (enum) node, it just looks like that because it’s hidden by the enumerator. The name of the enum variable is “State”, the state changes depending on which item the player is currently holding, you can do a lot with it