Download

Access to actors custom variable

I would like to make template actor, that has certain infos (variables like image, name string, link string). Then I would get reference to that actor and ask that certain variable/info.
So far, what I have tried, it doesn’t work. I tried to make actor, that has those variables and then set them “instance Editable” and from that actor, I made child blueprint class. When I open actor, that is made with that child actor, it has that one variable in the settings, but I can’t get that “variable” form other blueprints. I can see it in the actors default menu, but can’t ask it.
Other idea was to make your own structure, that has all the info variables in it and add manual that structure variable to all the actors. But I can’t access to that variable neither, if I just have actor as a reference.
Last option would be, to make own datatable with that structure and have actors as a row id. I was trying to find a way to get all actors from level and fill datatable with them in editor, but I can’t find the way to do that also… I was looking some python solution for that, but didn’t find.
So any good idea how to accomplish my task?

Hi, if I understand you correctly, then

if you just have actor as reference, then you can only access the functionality/variables of actor, not of your class. So you have two options

(-) cast the actor it to the class you use, then you will have access to all its functionality/variables (if the cast succeeds, so if the actor is of the type of your class)
(-) use an interface to retrieve the information you want, that way you can use it directly on an actor without casting (and ofc the class you use, needs to implement the interface)

Ok, then I will try interfaces. Haven’t really learn how to use them.
And that I mean by “actor as a reference”, that I get it by "clicking it (LineTraceByChannel) and that actor is then selected. Here is a link,how to I do that .

But one more question, so there is no way to make your own custom actor and then get variables from that with blueprint?

Sure, I described two methods above.
[HR][/HR]
If the question is, can I change the output of engine functions/structures to use my own AMyCustomActor instead of AActor, then the answer is no (altough you would get exactly that by casting the AActor output to AMyCustomActor).

If the question is, can I completely replace the AActor in the engine with my own AMyCustomActor, then the answer is no.

[SPOILER](Well the answer to both questions would theoretically be yes, by going through all the engine source code and replacing all AActor with AMyCustomActor, but imo that would be a really bad idea)[/SPOILER]
[HR][/HR]
If you have several different actors which are not following the same inheritance chain and that you want to have the some same variables/functionality, you can use an actor component for that, which would contain those variables and functionality.

ok, thanks for the info.
Also I manage to make it work with interface and actor child. I made actor that had that one interface, linked the values to the interface and then made child out of that actor. Then used that child for all me actors and they all had already the interface and variables in them. Thanks for this!

Ok, this almost worked…when I pack the project, in the game it doesn’t get all the actors info. The weird part is that, it works for some of the actors and not for others. Why, don’t know…
Also noticed that if I save again all the actors ( they are already saved ones), some of the actors start to work, but not all…So yeah, don’t know. I try to save and pack as many times it needs, to get all the infos.

You can try to refresh all blueprint nodes in your blueprints, maybe that helps. Also you can try and see if you get the same behavior in standalone (would save you the time of packing the project). And if you didn’t do already, enable iterative cooking and only pack the maps that you need, that should decrease the packaging time.