How do you set up a player controller that is able to control player player controllers?

I’m trying to set up movement for what I thought would be a very simple game, but I’m being bamboozled by how the player controller works. I need to have two pawns that can be controlled independently from one and other. These are going to be controlled by the same player locally and need to contribute to the same score. From all the stuff I have read the best way of doing this is by setting up a master player controller which is what the player controls. This acts like a brain for two other player controllers which each posses their own pawn. I feel like this is the ideal way of doing this as the master controller’s player state is what it going to hold the score. Right now this I’m trying to get this to work for local single player game mode but once I’ve got this nailed down there are plans to get have both networked and local multiplayer which is another reason why I feel the need to have a master player controller for each player which then controls pawns that will be spawned in as and when they are needed.

TLDR: How do I use inputs registered in the master controller to run scripts in sub player controllers that each posses their own pawn.

This is how I think the set up should got but I have no idea if my understanding of how player controllers work.

I’ve managed to set up something that mimics the effect that I am looking for by having one actor take in inputs that control the movement of two separate meshes within the actor. [I couldn’t make a GIF that was under the upload limit so here is a YouTube showing what it should look like.][2]

[I found a post on here][3] that was wither looking for something similar or the exact same thing that I am after. So I added their blueprint to my game mode and it looks like this. the game mode is set up so the master controller is the default and Pawn1a is the default pawn class.

When I use this code on all three of the player controllers they all print “-1” which makes me think that they are all connected somehow, but I also thought they should be printing 0, unless the value isn’t the player index and I’ve got that wrong.

Edit: I figure out that I wasn’t using setting or getting player controller, which is why it was returning -1 instead of 0.

240320-player-controller.jpg

If this is working as intended right then “YAY”. However I don’t know how to pass information between the blueprints in order to control the pawns. This is where I am stuck. How do I set up a script in the master controller that is able to take action events as inputs and use that to fire off scrips that control the movement of each pawn?

This is currently attached to the pawn itself but I suspect I need to attach it to the respective sub player controllers and make the pawn move along with the controller??? Anyway thanks for reading this far. If you have any thought or suggestions they would be greatly appropriated. [Also here is a Google Drive link with the source files so far, which is 22.5 mb unzipped][7].

what exactly are you trying to implement gameplay wise? like what functions, movement? whats the camera setup? you shouldnt ever need more than one player controller for each player to my knowledge so theres probably an alternative method to accomplish what your looking to do.

also your video is useless, its so low rex thats its hard to make out whats happening.

I’ve made a better video now and edited the link.

I’m trying to make a simple score attack game mode at the moment. So the player has control of one pawn and can move it in the four directions. Directing it to a pickup when the pawn overlaps the target moves to a new position within a grid and the player gets a point. The player’s goal is to hit X number of points before a timer hits 0. If they hit the score target before the points hit zero then they move onto the next round with a timer reset and a the score target is increased by a number. Eventually the player will be given a second pawn which they will control independently and will have it’s own pickup. Difficulty increases as the rounds increase. It’s kind of hard to play when your right hand is trying to control the left most pawn - that’s the real gimmick.

In the video I had input, movement, scoring, and camera setup within one actor. Meshes were used to move the mesh by 200 units up down left or right, as the poles are just there for visual representation. They also don’t align in the video because of some messing around I didn’t fix. Camera was just a part of the actor but didn’t move at all.

Now movement is based on the pawn finding the nearest object type and making a few checks to see if it fits some criteria. It then outputs the object and I’m telling the pawn to move to the root of that object. I’ve done this because I intend to have some of the poles seen in the video move during run time and this was the best solution I could come up with.

I’ve seen other’s describe the solution to this but I don’t understand how to execute. "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!”

Yes that sound’s exactly like what I need. I’ll see if I can figure out how to set up a custom ai controller that accepts inputs right now and let you know if I get it working, so you don’t have to waste any time. Also thanks in advanced for taking a look at it. I also thought of

where the pawn possession changes depending on which input it being used. Not sure if that would be a valid alternative approach though.

ok this makes a bit more sense now so theres two characters and you want to be able to move both. and your going to be using tow separate sets of input im guessing such as wasd for one character and the arrow keys for the other. in that case you will just need a custom ai controller that an accept the players input. ill try to make an example when i get back from work.

i came up with another solution that is easy to implement and seems to work. instead of messing around with all the ai controllers and things why not just reference the characters and set their movement from the one player controller. what this means is that all the code will be centralized and be easier to write and debug. the one problem with this method is that you need to know how many characters you need to control beforehand, but in your case it seems like you want to only have two the entire game right so no problem there.

the way i implemented this for testing was to spawn in two character at the beginning of the game (you could easily get references by another method) then i set a variable of type actor to the characters i just spawned, this gives me a reference to the actors i will be controlling. from there i just wrote a script for the movement inputs that correspond to each character (w for character 1, up for character 2). im sure this could be streamlined a bit but it works and shouldnt be hard to implement.