I know there are some really bright people on these forums! Alright, so I would like to have my third person character game to be able to switch between three characters. Each character has their own animation blueprint, and character blueprint already set up. I would ultimately like to set it up that two of the characters are AI allies, and the other one would be the controlled character. Each will keep their own stats i.e. health, current equipment, etc. but share the inventory. So does anyone have a good practice to switch the playable character via event or event dispatcher? Would it be better to just change the mesh or the blueprint entirely?
When you have 1 PlayerControlled character and 2 AIControlled characters in the same scene, you may want to do it this way:
In your PlayerController, make a swap event that accepts an AI Pawn or Controller:
- Unpossess your pawn
- Unpossess target pawn
- Possess target pawn
- Let a new (or reuse old) AI Controller to possess your previous pawn
Depends on how your camera is setup, your ViewTarget should adjust accordingly or you may have to manually set it. By default in ThirdPerson template, it should automatically.
That’s just one way of doing it tbh.
there is a built in playercontroller by default that is based in C++ if remember right, but alternatively you can easily create your own player controller which uses blueprint and set it to be used by default in the game mode. to create a player controller you just need to click the add new button in the content browser (green button) then select blueprint, then in the new popup window look for player controller.
the player controller is probably where you will want to store your inventory as well since its shared between the characters in a way or you could put it in the game mode.
I agree with your answer, however I am not sure where to find the player controller to make an event. I see it as a function that is built-in and I am not sure how to edit that function.