Hi, I am currently working on an inventory system for my game, however it seems like I am running into issues with the item actually being put into the inventory.
The main goal (or what I think I’ve been trying to achieve) is for you to look at the item, a line trace then detects that you are looking at the item, creates an interaction interface and sets a boolean to true. (Image from third person character blueprint)
It then checks to see what you are looking at and if that boolean is true, you would be able to interact and pick up that item. (Image from third person character blueprint)
Then, from what I understand from blueprints and event dispatching and whatnot, it’s supposed to send a “message” to Event Pick Up Item and run that code so that the item can be added to my inventory wrap box. However, it is not running this code below at all. (Image from item parent class event graph)
I have been messing with UE5 for some time but this is new to me. Any help would be greatly appreciated and apologies if my code screenshots or explanation are confusing.
First off you should be using an input to execute the interaction logic. Doing this on Tick means every frame your firing “visibility” trace and doing a whole lot of pointless logic. This is going to take a dump on your framerate as your game gets larger.
Second, you need a “custom” collision preset aka “profile” for your trace. So that your only popping a result if you hit something that’s interactive. Everything in the world (just about) blocks the visibility channel.
From there definitely implement a universal interface on “interactive” objects. You further filter with the “does implement interface node”. So only actors that use “interactive” profile for collision AND implement X interface will be able to process further logic.
Line trace by profile (Interactive)
Next you’re going to need to use either Gameplay tags (preferably the IGameplayTagAssetInterface [C++]), or actor tags.
The IGameplayTagAssetInterface implementation will allow you to get gameplay tags without casting.
Point here is you can use tags to identify an actor type (ammo, weapon, health) granularly so your code flow knows how to handle adding and removing easier.
Here’s a tutorial on how to set up the trace logic. It’s for multiplayer, but you can adopt it super easy for single player.
Here’s a snippet from mine.
Thanks for all this information, I’ll definitely start with the video and your screenshots and see where I get!
I’ll update soon
I just tried following the video and I might be missing something but in my third person character blueprint, BPI Trace doesn’t run unless pinned by Authority and not Remote like the video. Any reason this might be happening?