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.
I found a post on here 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.
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.
Follow this question
Once you sign in you will be able to subscribe for any updates here