Hey everyone, I have 5 actors in my game that the player can pick up (which sets a Boolean to true), then see an image appear in their HUD and have it stay there. I am wondering how to go about checking the Booleans each time after one of the objects is picked up. Thanks in advance for the help (attached is my HUD blueprint so far, just not sure how to connect them)
I’ve got this working, but only by sneaking in a basically infinite loop. Attached are pictures (one is just zoomed in). I’m wondering if there’s a better way to do this than what I have. Thanks!
(edit: whoops, see that I didn’t attach photos. Here’s what I have)
For this, you can just use a Sequence node or daisy chain cascade branches for the ultimate spaghetti solution.
I am wondering how to go about
checking the Booleans each time after
one of the objects is picked up.
You could create a custom event and connect it to the same nodes as the Construct and have pickups call it but… what’s the context here - player runs into a pick-up and something shows up on the hud?
The check should be happening when you pick the object up, surely not when the widget is constructed - the player does not have the items yet. And there’s probably no need to check all of them right? Just the one you’ve picked up.
Or how is this supposed to work?
It’s usually done via an event driven approach:
The player runs into a pickup, the pickup creates a new widget and adds it to player’s hud, setting booleans as needed. Wouldn’t it more logical this way round? Do tell as I might be missing the point here.
If all you need to check is a series of bools for {True} / {False}, use a Sequence node. Or better, add the bools to an array and For Each Loop - there’s usually no need for manual repetitive checks.
No pictures got attached.
I guess the reason I’m having this issue is that all of the images are in the same widget blueprint, it seems like you mean it would have been easier to have each image as its own HUD that displays when each pickup is gotten. I’ll give it a shot, thanks for the response!
If you really must use the original method, at least consider this:
to have each image as its own HUD that
displays when each pickup is gotten.
That’s the idea behind the OOP, objects is what you want to work with. You encapsulate behaviour and delegate functionality, have the objects handle some of the work. If in doubt, don’t hesitate to describe what the end effect is supposed to be like, as in:
- player runs into a pick up
- pick up disappears, widget confirmation pops up
- the picked up item now appears on the user interface, in the appropriate slot
It will be then a tad easier to suggest something more tangible.
Alternatively you can do something like this:
- All images placed into an array within one widget
- The widget has a function that takes an integer input and pulls that index from the array and sets the image visibility
- Within your pickup item you have a reference to the widget (how you get this depends on how you created the widget)
- The parent “pick up” has am integer variable to identify its image type
- You create child blueprints from this parent and change the integer variable
- When an item is picked up you use the widget reference to call the visibility function and pass in the pick ups integer variable value
- The function then uses the passed in value to identify the appropriate image to display
- You can also have a remove/hide function in the widget which will do the opposite when a pick up is used (the button press or however you use the item would then be linked to a particular integer variable so that the particular item used can be linked to an array index)
Not really an alternative but rather the proper way to do it.
@Nebula Games Inc: this pick-up item and add to inventory / slot question comes up so often that it might be worthy a full length tut video.
Haha, I just did one on the “Press E To Interact” issue. But I have avoided inventories because there are hundreds of ways to do it and different styles and each game requires different things, stackable inventories, drag and drop, some have random placement, some have specified slots, some are static in size, others grow as you add things. I feel like I will never make one that people are happy with. The other thing is, inventory systems are so integrated the tutorial is super long. I have to build a UI, set up all the buttons, create the pick up items, create the functionality for the player to interact with the UI and items both in the world and widget it gets really complex really fast even for a basic system. One of my first tutorials was helping someone create an inventory system that was supposed to add cloths to a character and it was a 24 min video for a static, dedicated slot, inventory system.
That actually makes sense, inventories are complex - you need to be ready, have your mind wrapped around the OOP at least, that and blueprints comms.
I feel like I will never make one that
people are happy with.
You must have prevented some hair pulling with the tutorials, surely!
Yea, I mean they are fun to make when I was doing them for my own purposes but because there are so many different variations you inevitably make one and then the comments start coming in “what if I wanted this or that to happen instead” “how would I get my inventory to be laid out vertically instead of horizontally” “what if I wanted this to just be grayed out instead of removed when the player has none” etc etc and it’s just like I seriously did 90% of the work for this you should be able to figure the small modifications out, I can’t make an inventory for every situation haha
You must have prevented some hair
pulling with the tutorials, surely!
I would like to think so but who knows. I am always amused by the people who “dislike” tutorial videos. Especially the basic ones I do since my descriptions are quite accurate and I don’t have catchy thumbnails but then people watch and get upset ha I have dislikes on a video where I teach people how to put a delay into a for each loop. Not sure what those people were expecting but apparently it wasn’t what I gave them ¯_(ツ)_/¯
@Nebula Games Inc another great tutorial, cleared some things out for me. Thank you.
I’m already following a tutorial on a fairly complicated inventory system (part 19/36 lol) and so far so good. Finally feels like I’m learning something.
I love the format of your videos, in good quality, your voice is pleasant and not too long (more then 20 min).
What surprises me the most if the fact that there are so many people that cannot follow a video, maybe they need a tutorial on “how to watch/pause a tutorial”?
Regarding Inventory systems, there are many tutorials on this subject, fair amount of good ones (that worked for me). I started with the tutorial from Epic made in 4.8 and it turns out it works just find in 4.22 if you just follow the video closely. People are just being lazy and think making a game is easy (I know I did when I first tried out UE4).
Great comments guys, keep it up. I’m watching you.