Download

local multiplayer game, player 2 running player 1's code, not sure what the problem is?

I’m building a small game for a class project and this is my first time using/learning unreal. It’s a small platform fighter with 2 players. The trouble I am having is that the attack animations for player 2 are running through player 1’s code. Because of this player 2 becomes locked in a t-pose animation until the level is exited. I currently only have two different characters for my game that I am spawning in between players 1 and 2.

Right now I have the player spawns within the stages (might move them to the game mode latter if I still have the time) and they work correctly, however once I try to reference player 2 in the code using either get player controller or get player character it doesn’t seem to reference player 2 correctly. I have player 1 spawned as player controller 0 and player 2 spawned as player controller 1.

I can’t seem to understand why player 2 is not being referenced properly. I’m not sure if maybe there is something wrong with the way I am using the get player controller with the player spawning or if it’s something else. Everywhere I reference player 1 I use get player character/controller 0 and when referencing player 2 I use get player character/controller 1. The reason I found out that player 2 controls were running through player 1’s controls was when I disconnected the movement controls for the player 2 character, player 2 would still move.

My attack animations are implemented within the character blueprints (again there is probably a better way to implement these) and each animation checks to see if the female or male character is either player 1 or player 2. This allows for the correct controls to be used for the right player.

The keyboard is used for the controls for both players where player 1 uses the left side of the keyboard and player 2 uses the right side. In total there are 3 different attacks and a block animation between both characters.

The images I have provided contain the code for the player spawning, the code for one of the characters attack animations, and an image of the player controls. The code for the player spawn connects as follows:

Player Spawning 1 -> Player Spawning 2 -> Player Spawning 3

The code for the attack animation is the same for all of the attacks for both characters.

I have been struggling to find a solution to this over the last week and it’s been difficult progressing with this issue. Any feedback is appreciated and hopefully maybe someone else has a solution that I have not tried yet. If there are any questions about anything that is confusing or that I missed mentioning, feel free to ask.

Thanks again