In my solo game, the player will play as several different characters and each character has his own gameplay (a wolf, a human and a bird).
for now, I have implemented the wolf and the human but I think about adding the bird now and after the last reunion we get with team of the project, it is more and more possible that we add a gorilla and an elephant.
I use the Quality Game Settings I bought on the market (here’s the manual).
This asset allow the player to bind the key he want for the game and that’s why each input is deals by BP and all of them pass through the controller BP.
In my controller BP, I have a lot these things :
I will soon change this to set a variable (int or string) for each playable character and replace the branch with a switch…
Then, the events are managed by the character BP and every thing’s fine ^^
My concern is that for each input, I will make this switch thing to redirect the event to the character actually played. I’m afraid that this cost me a bit in performance…
Should I make several controler BP (one by character) and change it in runtime, when the played character is changed ?
Or maybe the cost I fear is very small and should not be bothering me (it applied only on input, after all…) ?
In the case I keep all in one controller BP, I will remove the “is Valid ?” Node… I know what character is played
Edit : It seams I can’t easily swap controller at runtime… So I will put every thing in the same controller BP
Is there a better way to deals with the numerous switches I will have then ?
When you say “a function for each input, function that does nothing”, you mean have an event that triggers nothing in character_BP and does something in gorilla_BP, or I have to create a “real” function that is trigger by the event and redefine this function in the child BP ?
Don’t mind to answer this, I will do the test ^^.
Make an Interface which mirrors the Inputs and let your Character/Pawn implement it.The Controller simply calls the Interface functions on the Controlled Pawn.
You don’t have to distinguish between Pawns this way
So, Mr Interface, we meet again…
I definitely need to learn what are these interface thing, it’s the third time I heard of them.
I have a lot of work, then
I bet all of your characters are sharing common properties like health, energy or whatever. It would be easy to code them in the character parent class and then modify / override the functions you want in character child classes.
In fact, your solution please me a lot because I understand it and it seams natural to me
But, I see an opportunity to learn something with the raildex way ^^
I think I will implement the two :
Yours for the final result and the one from Raildex to learn about interface.
I feel this is important