Download

Multiple Player character for one player?

Hi !

We are doing a game where the player can control some NPC.
The idea would be that, in some scripted location, the player will be able to “press a key” and “leave his body” to control the NPC.

Now, all NPC will have an AI, so a AIController. But will probably need the Character_Controller to be able to be controlled by the player.

Is it possible?

I don’t know that much of UE yet, but, what I’m planning to do is to make a basic Character with an AI Controller and a behaviourtree.
Then, when the player use the key and control try to control the NPC, I would like to disable the AIController AND the Behaviour tree, and enable the Player_Controller and camera of the NPC (or adding this component).
Then, get back and reenable the behaviour tree and the AIControlled

Is it possible?
Thank

Hi,
Very doable. I’m not super experienced but I have a character that controls a pet. I basically created an empty blueprint with my pet in it. I then created custom event of behaviours I want the pet to do. Attack to target, Come back with inputs Target and Owner location. Then in my character Begin Play Event -> spawn that pet. Now that pet will see my character as owner. I then add a press key event, reference my pet, cast to the pet’s class then call functions Attack Target and feed it with Target (location). Same thing with Come Back event.
Not the best way but it works fine for my little needs. Probably one experienced member here will give you better solution.
Hope this helps

Hi, thanks for the answer :slight_smile:

if I understand your example, you control a cat by giving him commands with the player you control. That is not exactly what I want to do.

What I would like is, to “swap” the player controller with an AI. So that basically :

====> You control character A at location A² with your keyboard
====> You see an NPC patrolling (with a Behavior tree) with is character B
====> You use your power to swap your A body with the B body of the NPC
====> You now control character B at location B² with your keyboard, (character A will stay at location A² without moving until you retake control of him)

Here:
https://docs.unrealengine.com/latest/CHN/Gameplay/HowTo/PossessPawns/Blueprints/index.html
or
https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/APlayerController/Possess/index.html

Hi, thx for the link.

I have seen those tutorials, but in all of the cases i see, the player use the same character and/or the same controller.

In my case, i want to temporary switch or disable a custom character and controller (since my character/controller on the NPC are AI, and to get controlled i need a basic Controller and AIController, and reset them later.

Is this possible?

Just want to know the simple line on how a good UE user would do that, cause I m new and I will maybe choose the worth path for that.

You can possess any character class, no matter which class it is; if it’s a child of Pawn class it can be possessed by any player controller even if controlled by AI.
And you don’t need different controllers if you process different input schemes in the Pawn blueprint. To change Controller class a Player is using would require to edit in C++ code your custom GameMode class while the game is running, would over complicate things.

Yes, you want to do Possess. Much easier than what I explained.
https://www.youtube.com/watch?v=EsOk-tERCaQhttps://youtube.com/watch?v=6wHRmN4F2LoEven if character look the same they are actually different characters.
I’m using this to swap my character between 5 different characters.

Thanks :slight_smile:

Just a quick question, about what you said on the controllers.

My basic player use an AIController.
My basic AI use a NPC_AIController (i need a different version of AIController since i must start the blueprint)

So, it will work if I try to control my NPC_AIController (and say instide his blueprint to disable the behaviour tree while possesed) ?

The