[SOLVED] Moving two pawns with one PlayerController?

Hello all,

I’m having trouble figuring out the best way to do this.

I’m making a single player 2D game (I might want to network it later but for now that’s outside of my scope) and for now I have a character and a pawn sharing a player controller. I need for the player to be able to move both the character and the pawn at the same time, bound to different keys (for example, move the character with the arrow keys and the pawn with wasd) They also must share a camera, specifically tied to the character. Gravity and animation must also still occur like normal while the pawn is moving, so no trading of control between the two actors.

My problem so far is the best I’ve been able to do is a trade; I can control both actors but only one at a time; so when I move the character, the pawn won’t budge even if I’m holding d or a, and vice versa for the character with left and right. Animation also gets stuck while the character isn’t possessed.

I’m using the Possess(); method in my custom playercontroller depending on which InputAxis is called (wasd is always tied to the pawn; arrow keys are always tied to the character). I move actors with AddMovementInput(); and the pawn does have a movement component that I added. I believe the problem may be related more to a playercontroller only being able to control one actor at a time (the one that’s possessed) but I’m not positive.

An unrelated problem that might be throwing me off somewhere is if I don’t add a bool check for possession it gunks up movement; actors move very slowly because of the constant possession and re-possession for some reason that I haven’t been able to really trace yet.

I’ve considered routing inputs through an invisible “brain” actor but that ties back to my not really knowing how movement in Unreal works fully. I don’t think AddMovementInput() will work with an unpossessed pawn (Please correct me if I’m wrong) and I’d rather keep my input code contained to the playercontroller class if possible.

tl;dr - I need help finding the best way to structure and route movement through two pawns - what’s the best way to accomplish this?

Thanks! If you need any more details I’ll be happy to provide them

After reading around some I found a solution

Give each pawn its own AI Controller (PlayerController should work fine too I think) and have a master PlayerController act like the “brain” which routes the commands to them. As long as each pawn has its own controller you can move them at the same time on controller index 0

Solved - and thanks!