Using a blueprint instead of s Struct

I was wondering if it’s valid to use a BP object reference instead of a Struct for storing a collection of variables.

for example:
LineTraceByChannel returns a Hit Struct with quite a lot of variables I can use.
But i only need 1 or 2 of them. Now I can’t just pull from the struct and go “Get Hit Location” to get that variable, I need to break or split the struct to see it and use it, but then i have this huge list of Variables I’m not using and they take up quite a bit of screen space.

So that’s why I’m wondering if there’s any downside to just use a BP as a return value for my functions instead, that way I can just pull from the BP only the variables I need.
I know this might seem overly OCD-ish, just because it takes screen space but there are some more advantages to using BPs instead of structs (like BPs inside BPs)

does using BPs encumber the memory more than structs? is it not optimized? or is it entirely up to me and the whole BP system decides on memory handling all by itself?

thanks for any answer

It sure is valid, who’s gonna stop you - The Blueprints Police?; I don’t think so! But you could do this instead:

Also works the other way round:

But seriously, do not use an actor for this. You could use a data asset if you want to stay away from structs since those can be *crashey *& quirky at times. Apart from the memory footprint implications, what happens if you need to send this data somewhere; plugging in dozens of pins will give you a mild case of severe carpal tunnel syndrome.

Lol yeah i know i can use whatever i like but there are certain conventions and Don’t-Dos that apply
this example doesn’t really help me. i know i can split and break structs and that’s what i want to avoid.
here’s an example of what i’m referring to:

← I only need this variable

I don’t need all the rest of these

← Isn’t this more readable?

If i need to send the data i send one actor reference with it’s variables or i can pick the variables i want from that actor and send just them

is that not recommended?

You break the struct and hide the pins you do not want to use, that saves tons of space, no? Or collapse the node as seen below. Wrap things with functions, write getters for stuff you use often, use macros and so on:

Screenshot 2020-10-05 194010.jpg

That’s all cool and well if you have a simple game and a dozen or so actors that hold some variables each, sure.

  • what if you need 1000 structs? It’s not uncommon to go into millions of structs…
  • what if you want to use the blueprint’s save game system & must have nested arrays of structs, not sure how one would go about saving thousands of variables one by one
  • what if you need a data table
  • what if you need to format rich text
  • whatifs are too numerous to count!

If you really want to use 1 actor instead of 1 struct, then I’d say don’t or I am calling the blueprints police right now ;). All of the above sounds a bit inconvenient when compared to this:

Also, hard references are never fun to work with. You end up spamming isValid everywhere. And then there are circular references.

Ok got it
Thanks for your time :slight_smile: