Download

Getting information about items in game

Sorry if the title is a little misleading. I need to get some data from items in my game. I have set up a trace to get the distance to the item and the item name, but I was hoping to get some variables as well (such as clues as to what the item might be for, or the weight of the item etc…) I can get the hit actor, but I am stuck from there. I don’t really know if I am going about this the correct way. I want to be able to gather this information on a key press and if there is no variable available then just return a value of “Unknown” or “N/A”. If anyone needs more information please ask. I haven’t included any screenshots as I am not sure where to even start this.

If the item is an actor, then put the variables you want in that actor. Then on ray trace you should be able to grab that item and pull the variables from it that way.

That’s what I need to do, but how do I get the variables out of the actor? I can’t seem to cast to it as I need to specify the actor to cast to and at this stage it is unknown.

Got most of it, just need help setting the value within the blueprint.

Let’s say you need the float var “Weight” from an actor (or multiple) , create an interface BP and create a new function “Get Weight” with a new float output inside of this BP. DONE

Then in your actor go to class settings and implement the interface. DONE

After compiling and since the interface event has an output, you should see the function “Get Weight” in the list of function. NOPE

Simply open it and connect the variable health you wanted to get.

The bit I don’t understand is that if the function has an output only, how does the value for Weight get into the function to produce the output for the trace?

Nailed it, thank you so much.

Personally if your going to have multiple items it would be best to use a data table to store all your item data such as weight, description, clues, colour or even damage when eaten. This way as long as you have the item name you can then get the item information from any where by getting it from the data table.