Shown here is the ability to set a blueprint variable to a class which the blueprint could later use to spawn that type of actor. Though polymorphism it is shown that the editor is aware of compatible classes of the selected class.
My code at the moment attempted to use pointers to allow blueprint to specify the object and let my class get the object to call from but that required an already spawned object and since my class inherits from UObject and does not provide any visual or scene aspect to the engine there isn’t a way to spawn one that I know of.
UTurtle * TurtleMesher; // Inherits from UObject
I would like to be able to select a base class and then select classes that inherit from that base class and show them in the drop down menu. I don’t know if C++ has that ability or if it was something that only blueprint can do.
this code to try and make it so I can give the C++ script an object but the object isn’t allowed to receive it unless it’s already made and I can’t spawn it. What I wanted to do was give the C++ script the ability to spawn it’s own object given through a variable and use polymorphism to store it using the base specifier of UTurtle and anything that inherits from UTurtle can be stored in that variable.
I would like this menu below in the menu in the next picture. But I realize that can’t be done as long as it’s a pointer.
otherwise in most cases you want to derive from actor and spawn or place inside a map even if you write a manager actor, you can easily spawn it in the map.
im not sure what you are trying to do but from your screens and what you described i guess you are better by going the actor way as they have a UWorld context and you have much more functionality (please correct me if im wrong)
That wasn’t exactly what I was trying to do. The UTurtle is a class that makes points on a line and I wanted to make it inherit from FRunnable later on. The idea was that I could change out the UTurtle in the owning C++ class and then change it’s functionality based on the given UTurtle since later on I could inherit from UTurtle and override functions that exist in the parent class that would change the output of UTurtle. The reason why I need to spawn UTurtle is so that I can do two things, Separate my classes so that it’s not one big mega class and two the turtle needs to have it’s own data per instance but provide a single function interface to that data. I don’t even know if C++ can do this and even if it can though templates I don’t know if UE4’s reflection system supports templates.
I’m not deriving from actor because this is basicly only a utility class but I want it exposed to the editor as an option to select so I thought I had to derive from UObject, the turtle class is a utility to create points for a procedural mesh component so while I’m not technically putting this in an actor it does go into actors to be shown in the world but none of my objects need an actor component but rather go into actors.
Of course you can use all advantages of polymorphism to avoid mega classes, but as more you derive as more errors can get into your code if you don’t plan your classes extensively BEFORE you work it out.
I still don’t know why you don’t derive from actor and then derive it logically into those parts you want it as your final object will be…actor!?
here is an old tutorial about templates in UE4 by rama
ok i understand but i don’t know if you can go this way i guess not as it seems to go straight against the architecture how unreal works (Actors in Unreal Engine | Unreal Engine 5.2 Documentation).
you would have to write your very own system and break the complete architecture how unreal works (correct me if i am wrong).
i would take a look into components… if you derive from aactor and instance your uturtle protected/public you can call those base functions in all childs even if you decide to create a component for the view part