I’m new to UE and i’m trying to figure out how to set up my project.
I have some base class which few other classes derive from. Each derived class has its own mesh ,texture ,… , which I set up with blueprints. How do I use those blueprints when i want to spawn some instances of those classes ? All instances are spawned trough some controller class.
Is that even possible or i have to hard code all that stuff ?
I’m not sure that’s it. I want to apply already made blueprints to an object which i spawn trough code ,not editor ,who’s transforms are also controlled in code.
Let’s say I have some class named Cat and I create a blueprint for it too.
Now i want to spawn 20 of those Cat blueprints somewhere in the world trough some logic in c++.
How do i do that ?
In C++ you have to get the reference to your Blueprint class. You can either use Constructor helpers to hard-code the path to your Blueprint or use UPROPERTY (variable of type TSubclassOf) to do that. Once you get it, simply use SpawnActor() (look at the documentation for examples).
In my controller class ,with TSubclassOf , i can get the reference to one of derived class blueprints and then spawn it. I do that by creating a blueprint of controller class and changing ‘blueprint to spawn’.
What i don’t understand is how do I set default blueprint for each derived class. I don’t want controller class deciding which blueprint to pick. It should be on each of derived class to do so.