Download

How to use different characters

Hello, I have finished my team system, and now I would like to get different characters depending on the team. Should I create differents actors? But everytime I do something directly with them, I have to make a different “cast to”. Or should I better use the same actor, and set different variable value and change the mesh at the construction? Or maybe there’s another way to do that. Thanks you for your time :smiley:

Hi @feuef

I am pretty sure that , if all your chars shares all same behaviour and change only the mesh and animation, you should set them as variables.
Keep in mind that you can also have “child” classes

Well since you finished the team system, I’m sure you have a way of assigning players to a team. If that’s the case, while still in loading screen, get player team, if player team = 1 (Team 1), cast to playerBP1: the character you want to change (pretty sure that’s how you do it, haven’t really messed around with character changing) If player team=2, cast to playerBP2, and once all that is done, you could stop the loading screen and set input mode game only. Not 100% sure that this would work but it sounds really simple and wouldn’t take a lot of resources. But for this, I do suggest using the same actor as your team system.

Child? What does that do in this? It doesn’t mean the “child” classes earn the blueprint from the parent ? (never used them sorry)

Well, I tought I could do something better than that, cause I made a lot of cast, and with so many classes it would became very time eating

Hi, you could use inheritance. So you would create one parent class (or a chain of them) where you have all the functionality, and then each of your different characters would be a child class of that parent. Then if you want to cast, you cast to the parent.

The child class inherits all the functionality from the parent class. And you use them all the time, everything you place into the world inherits from “Actor”, and every time you create a new blueprint you specify from which class you want to inherit =)

Inheritance is a really strong tool and you should familiarize yourself with it, cause it will greatly help your productivity.

Oh ok, I didn’t tought that I could do something like that :smiley: Thanks you a lot, I gonna try to make it work ^^