How to find variable in the BP if output is generic "Actor Object Reference"

Greetings all,

I’m wondering, is there a way, when using get actor of class, but the “Actor Class” is connected to a data table, to check if a function or variable exists on that BP without casting to that actor?

The “Get Actor of Class” will get the BP I need from the data table, but the output is still a generic “Actor Object Reference”, can I some how still check if what I want exists from that Object Reference, without casting to that BP, since the Object Reference already references that BP from the DT… I’m not sure if I’m even asking this correctly.

Thank you for the help!

Picture - Small example!

Is the Actor Class value in your struct of generic type… or a base class that contains the variable you need?

It’s an an “Actor” class in the structure, then in the data table I have it set to the correct BP.

In that case it will be a little bit harder for you to get to my personal solution but there is another way.

You can use an interface and implement the interface on all the actors you need to do the functions and return the variables you need. An interface in practice makes sense if your actors are unable or you do not wish them to share a parent actor.

My suggestion, as long as you do not require an interface as mentioned above, would be to create a base class (you can reparent the actors you already have through the class settings window) that contains the functions and variables you need to be present in all actors.

With the interface you will not have to cast. With my second solution you will have to cast to the base class.

2 Likes

I will go and try your suggestions.

Thank you very much! =)

Edit:
Using an interface did exactly what I wanted, thank you again, Conner!

1 Like

No worries mate!

Cheers!