I trying to figure out how to make game like “Brothers: A Tale of Two Sons”, where one player can control two characters at time.
In Character class you can set 1 mesh and there is only 1 movement component. Also, every character should be animated individually.
So, maybe I need to create 2 characters and connect them to 1 player controller somehow?
Create two controllers, each responsible for handling it’s own input for it’s own character.
Since both controllers get info based on mapped actions and axis. being one “physical (xbox, keyboard)” controller is no issue.
Any shared data between them two, store in the game state or such.
IMOP, The first character use the standar metode, the second character can be spawned and registrer in the player controller as variable type actor. Them the controller can send events to the secons character.
I thought you meant that it would be exactly like two brothers, their on a controller you controll one per analog stick. Then you would just have to controllers, each controller checking the axis that is relevant to it feeding that to the same functions in it’s own character.
No no. Like I said, Two characters from one physical controller. I wrote two brothers, I meant Two sons.
My point still stands, make two controllers, PlayerControllerBrotherA PlayerControllerBrotherB. One controller read the axis from the left analog, the other from the right analog. Both feed in to the same functions for movement the character they are connected to.
One friend tell me that I can use simple player with spectator pawn and 2 AI characters, which can be controlled from player controller.
So PC gives to AI some commands to move and interact, when player press some buttons.
I’ve done something very similar recently. I wanted to control a character and a vehicle at the same time. All I had to do was to add Spawn Default Controller node to my vehicle.
In your case you could use a spectator as a main controller and spawn your characters in blueprint. Where you creating your characters add Spawn Default Controller node for each of them and plug them into their respective nodes. Map their controls like you’d normally do inside of every character blueprint, using input events or axes. That should do the trick and they both should be controllable at the same time.
First of all I have create input mappings for every character (MoveRight_A, MoveRight_B, MoveUp_A, MoveUp_B and so on)
Then create simple character only with camera and set it as default for my game.
In it’s Event Graph I spawn 2 another characters (with meshes and other components) and store them as variables + spawn default controllers for them (without it movement and physics not working).
Finally I add input events to default character and pass it into this new 2 characters through custom events.
Now, 1st can be controlled with WASD, 2nd with Mouse axes, or both with correspond gamepad sticks.