Cast to character, but multiple playable characters? Methods and tips?
Is there any good way to handle casting to a character, but not make it character-specific? As in, I have multiple playable characters, the player can select which character they want to play. But when setting up various functionality, especially when following tutorials, the cast to [insert specific character] is used extensively.
Now, I have gotten around this so far by using BPI messaging and events and all AI interaction has been fairly simple to set up this way. Currently I am making UI and inventory/equipment/skill systems and it's getting very convoluted and difficult to keep track of.
So I was wondering, does anyone have any tips on ways to be able to communicate with character blueprints without referencing a specific character blueprint?
I would prefer not to use get all actors of class at all if possible because of the taxation on the engine.
I've been exploring the parent-child setup, ie you have basic character blueprint, and all your different playable characters are essentially made as a child class of that character blueprint. Anyone got any insight on this? The idea would then be to store all the shared variables and functionality, like item inventory, equipment, and various UI interfaces, in the parent blueprint and communicating with that.
asked Feb 06 '19 at 02:14 PM in Using UE4
for storing things like stats and other qualities that are common among many characters, inheritance (parent child) is the way to go. by taking advantage of inheritance you wont have to create a variable in each class for something like health, the child classes will inherit it from the parent class. it also means that you wont have to cast to multiple classes when trying to get the stats, you can just cast to the parent class. its like the relationship between pawn and character, characters can do everything a pawn can do and much more. so your parent class would have the basic functions and variables and the children would have things specific to the role like abilities.
answered Feb 06 '19 at 02:42 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here