top of page

Using Structs for Inventory

I figured out how to use Structs in blueprint in UE4. A Struct is created as an asset in the content browser. Its purpose is to hold a list of other variables and it is handled like a variable itself. Give it a name like YourStruct, and enter variables that it should include and their default values:

(Name)Name=None

(Int)Cost=0

(Bool)bQuestItem=0

(String)TextInfo=None

(MaterialInterface)Icon=None

That list can grow really fast depending on what's required for the struct to be useful.

In blueprint, you make variables of the type YourStruct. These might be named Item1, Item2, etc.

Drag out set Item1 and get Item1 into the eventgraph. From the pins, you can MakeStruct or BreakStruct.

MakeStruct lets you assign new, distinct values to the vars in the struct for the relevent var, for instance in Item1 the var Name value of Sword. In item2 the var Name gets a value of Axe.

BreakStruct lets you get current values for vars in the struct.

If you look at the Details panel when a MakeStruct or BreakStruct node is selected, you will see that there is a Show Pins option to expand, and from this you can tick for a given node which vars the node will show in the graph. This is very handy as it lets you pinpoint just what you need for a given case.

James Golding has posted news (for an upcoming release) that there will be an option to expose struct contents in a new way. A vector is a struct that contains 3 floats, XYZ. https://twitter.com/EpicJamesG/status/478856855478079489

Featured Posts
Recent Posts
Search By Tags
Follow Us
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square
bottom of page