# controler BP and different characters : best practice ?

**URL:** <https://forums.unrealengine.com/t/controler-bp-and-different-characters-best-practice/100880>\
**Category:** Blueprint\
**Tags:** unreal-engine\
**Created:** [October 6, 2017, 2:00pm UTC](https://forums.unrealengine.com/t/controler-bp-and-different-characters-best-practice/100880 "2017-10-06T14:00:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![JoGoiA](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JoGoiA](https://forums.unrealengine.com/u/JoGoiA)\
**Post date:** [October 6, 2017, 2:00pm UTC](https://forums.unrealengine.com/t/controler-bp-and-different-characters-best-practice/100880/1 "2017-10-06T14:00:35Z")

</div>

Hello every body !

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](https://www.unrealengine.com/marketplace/quality-game-settings) I bought on the market ([here’s the manual](https://drive.google.com/drive/folders/0B6q3m_1GCs3ufnNTRXQxNFlhVWpMXzhveG9Wa3lKUDZhOG51ZmYzN2FLTEVpQmpZTGc5eXc)).  
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 : ![controler-3.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/3/5/359222c30774f1fee9ac9ec7eb6d7dbd43ca4256.jpeg)

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 ?

---

<div class="post-metadata">

**Author:** ![Yun-Kun](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Yun-Kun](https://forums.unrealengine.com/u/Yun-Kun)\
**Post date:** [October 7, 2017, 10:25am UTC](https://forums.unrealengine.com/t/controler-bp-and-different-characters-best-practice/100880/2 "2017-10-07T10:25:02Z")

</div>

Yup there is one.

- “BP\_PlayerController” -\> listen to inputs
- “BP\_PlayerCharacter” -\> has a function for each input, function that does nothing
- In your “BP\_PlayerController”, create a “CurrentCharacter” variable of “BP\_PlayerCharacter” ref type, it is a pointer to your current Character
- “BP\_WolfCharacter” and “BP\_Gorilla” are both child blueprint of “BP\_PlayerCharacter”
- each of your “BP\_ChildCharacters” override the input function to do what they need to do
- when switching characters, you update the value of “CurrentCharacter” in your “BP\_PlayerController”

---

<div class="post-metadata">

**Author:** ![JoGoiA](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JoGoiA](https://forums.unrealengine.com/u/JoGoiA)\
**Post date:** [October 7, 2017, 11:26am UTC](https://forums.unrealengine.com/t/controler-bp-and-different-characters-best-practice/100880/3 "2017-10-07T11:26:59Z")

</div>

Ok, thanks a lot **[Yun-Kun](https://forums.unrealengine.com/member/32515-yun-kun)** 🙂

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 ^^.

Thank again !

---

<div class="post-metadata">

**Author:** ![Raildex](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Raildex](https://forums.unrealengine.com/u/Raildex)\
**Post date:** [October 7, 2017, 12:29pm UTC](https://forums.unrealengine.com/t/controler-bp-and-different-characters-best-practice/100880/4 "2017-10-07T12:29:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JoGoiA](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JoGoiA](https://forums.unrealengine.com/u/JoGoiA)\
**Post date:** [October 7, 2017, 1:40pm UTC](https://forums.unrealengine.com/t/controler-bp-and-different-characters-best-practice/100880/5 "2017-10-07T13:40:00Z")

</div>

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 🙂

Thanks for the lead, **[Raildex\_](https://forums.unrealengine.com/member/216469-raildex_)**

---

<div class="post-metadata">

**Author:** ![Yun-Kun](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Yun-Kun](https://forums.unrealengine.com/u/Yun-Kun)\
**Post date:** [October 7, 2017, 8:51pm UTC](https://forums.unrealengine.com/t/controler-bp-and-different-characters-best-practice/100880/6 "2017-10-07T20:51:29Z")

</div>

Yeah that’s also another way to go.

But to me it’s not the best case scenario here.

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.

---

<div class="post-metadata">

**Author:** ![JoGoiA](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JoGoiA](https://forums.unrealengine.com/u/JoGoiA)\
**Post date:** [October 7, 2017, 9:05pm UTC](https://forums.unrealengine.com/t/controler-bp-and-different-characters-best-practice/100880/7 "2017-10-07T21:05:23Z")

</div>

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 🙂
