x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Why do controls only work for one player in local multiplayer?

I've been banging my head against this for a while now. I've read every related Q/A or forum post I could possibly find on the topic, and none of it has provided an answer. Hopefully you guys can help.

I'm building a local multiplayer game and so I have a loop that spawns 4 different characters into their respective corners of the map. The players spawn in just fine, but while my first character receives input from the first gamepad just fine, the second character refuses to receive input from the second gamepad (and I assume the same would be true for 3,4 supposing I had more gamepads plugged in).

I also tried running an "Is Local Controller" test on the playerControllers just out of curiosity. The first controller returns false, while the latter 3 return true?? I don't know if this is related to the problem, but it makes my head hurt.

Here is the blueprint I'm using to spawn the characters. The right half of the BP is the real meat and where the issue seems to lie (I think). alt text

Thanks in advance to any and all help.

Product Version: Not Selected
Tags:
charspawnbp.jpg (515.4 kB)
more ▼

asked Oct 30 '14 at 10:35 AM in Blueprint Scripting

avatar image

Kapos
16 4 6 9

avatar image Kapos Nov 03 '14 at 06:49 PM

Has anyone successfully gotten local multiplayer working with blueprints?

avatar image eXi Nov 03 '14 at 10:58 PM

As far as i know, on a local machine, different players are seperated by the controller id. So if you want to get a specific player, you call "Get Player Controller" with the ID of the player.

Note: Only for LOCAL Multiplayer.

So including this information into our spawning process, would say you need to increment the "Controller ID" of the Create Player node by 1 everytime you spawn an additional player.

So the first player is 0, the second is 1 etc.

You are only using -1 (i don't even know what UE4 does with -1, maybe it just makes a 0 out of it) for every player you spawn, so every player you spawn, overrides the Controller ID. If i'm correct, the last spawned player should be the one you are controlling with your gamepad.

avatar image Kapos Nov 05 '14 at 01:31 AM

The -1 tells it to assign the next available ID, so in theory it should just iterate through 0,1,2,3. Also, I've tried using Get Player Controller, but that wasn't working either, so I went back to directly referencing the Controller through the CreatePlayer node. Is that wrong?

avatar image eXi Nov 05 '14 at 07:11 AM

I haven't used create player till now, so could you answer me a question? The Create Player node does return what? The Player Controller? Just to be sure, plug the Index of the for loop into the Controller ID.

avatar image Kapos Nov 19 '14 at 09:51 PM

UPDATE: so I've discovered that player 0 is actually the only player of the 4 that is not working properly. When I start the game with the players spawned a ways above the ground plane, players 1-3 fall down to the ground plane while player 0 stays floating where he spawned.

Before I had been using 2 XBone controllers and a PS4 controller and it wasn't working, but I went out and bought a third XBone controller, and now with the 3 xbox controllers plugged in I am getting control over 2 characters. So, I assume the first controller is assigned to the playerController that isn't properly connected to Player 0, and so then the subsequent controllers are working fine.

So ultimately the question now is- why isn't my Player 0 working properly while the others are?

avatar image Doug E ♦♦ STAFF Nov 20 '14 at 01:19 PM

Hey Kapos-

I have a few questions to make sure that I understand what you're seeing. Are you able to use the keyboard to control player 0? Also, what do the other players (1-3) see when they look at player 0? Is he still in the air in their view as well? Which version of the engine are you working in and do you see the same behavior if you open a new project?

Cheers

Doug Wilson

avatar image Kapos Nov 20 '14 at 11:22 PM

Hi Doug.

The keyboard does not seem to work either to control player 0. This game is a single screen (not split) local multiplayer, so everyone is seeing the same thing and there are no individual views. I tried migrating my character and game mode to blank project- this produced slightly confusing results. In the blank project player 0 at least fell to the ground, but I was still unable to control him, while I could control the other players.

In my actual project while player 0 is the only one that doesn't fall to the floor, he at least is receiving his idle animation. Any thoughts?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Hey Kapos-

This problem has been addressed internally and should be fixed in a future update for the engine. Thanks for bringing it to our attention and best of luck in your projects.

Cheers

Doug Wilsopn

more ▼

answered Nov 25 '14 at 06:27 PM

avatar image Kapos Dec 02 '14 at 08:45 PM

That's great to hear! Thanks Doug.

avatar image Kapos Dec 10 '14 at 11:38 PM

Hi Doug. Was this expected to be fixed in 4.6? I've made a copy of my project in 4.6 and the problem only seems to have gotten worse. Now, the 4 characters spawn, player 0 remains in the air in his idle animation, players 1-3 fall to the ground, but none of them respond to the controller input anymore. Any thoughts?

avatar image Doug E ♦♦ STAFF Dec 11 '14 at 04:08 PM

Hey Kapos-

Using a slightly modified version of your blueprint above, I was able to create 4 players, each controlled by their own controller. The changes I made were to create a variable out of the Index coming from the ForLoop and connect it as part of the loop body before the Switch o Int. Then rather than use the SapwnActor node I added a Set Actor Transform with the Spawn Location variable set as the New Transform. I added a Get Player Character node with the Player Index set to the index variable from the ForLoop and connected this to the Target of the Set Actor Transform. I was able to set this up inside the level blueprint however you should be able to set this up inside the player controller as well.

avatar image esquire Dec 12 '14 at 08:43 AM

Hey Doug,

I seem to be suffering from the same issues stated above. I'm in 4.6 and "create player" doesn't seem to be making anything. After spawning I can check my outliner and see there is only one instance of my controller. Any ideas why or what is going on with this node in 4.6? I can get other controllers to show up IF I check spawn pawn on create player.

My setup is very close to Kapos, and I have tried it several different ways. I had a similar setup to this working perfectly in 4.1, not its broken. I get one of several results. No players controlled. player index 0 works, but not 2-3. Or 2-3 works but 0 will not work.

avatar image esquire Dec 12 '14 at 08:58 AM

I must admit... I feel a bit stupid.

After a little persistence and trying different methods I got it working, but something is fishy. I noticed each time I was testing debugging, I was losing focus on the game window, therefore NO INPUT was being sent to it, Appearing as those my controller were not working. Also, I feel like I was getting different results based on where I hit Play from. Either in my controller or in my level BP. I also had to separate out the creation of players, spawning characters and possession into 3 different steps. Not sure if I go back and try it all in one loop if it will work this time. Here is a shot of my BP if anyone else is interested.alt text

Top portion is in the level BP. Bottom portion goes into each of my characters that I setup.

I actually use a "player number" variable so that I can capture a reference straight to my characters controller (player1-4), since their isn't currently a way to do that it seems like, at least not that I know of. It would be nice to have a Get Controller, or Get Owner node that works for characters or actually returned a Player Controller.

ue4help.jpg (992.6 kB)
avatar image Doug E ♦♦ STAFF Dec 12 '14 at 03:38 PM

Hey esquire-

It is expected that the SpawnPawn checkbox of the Create Player node needs to be checked in order for addition controllers/pawns to be created. After some additional testing I found that the "SpawnActor" , "Possess" , and "Enable Input" nodes from Kapos' original setup are not necessary for creating players as each of these processes are handled by Create Player. In a fresh 3rd person template project I was able to use the setup shown in the screenshot below to create four players in each of the corners of the level. This is primarily the same setup that Kapos posted originally with a few extra nodes for setting the location of the actors.

alt text

creatingplayers.png (223.4 kB)
avatar image Shadowsora Jan 08 '19 at 04:40 PM

I was wondering if a solution has been found to Kapos issue with player0 as in 4.20 I am seeing a very similair if not the same issue. I've placed two PlayerStart points and in just starting up regularly Player0 works fine, but in spawning in a second player the camera for Player0 teleports behind the level and Player0 no longer recieves input from the first gamepad, but the second player is controlled by the second gamepad. Spawning more players does not effect the second player and they function normally.

avatar image mightyenigma Jan 08 '19 at 05:02 PM

I am guessing your problem is not due to that bug because it has been solved. I would recommend you start a new thread for your problem and post a blueprint showing how you spawn player pawns and possess them. That should give most of the information needed to solve the problem.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Hey Kapos-

In your Spawn Actor node you are setting Player Num to 0 each time a player is added which will override the previous player. What you'll want to do is create a variable that starts at 0 and connect it to the Player Num of your Spawn Actor node. After the SpawnActor node, include a set node for that variable that increments the value by one. When the loop runs again it will assign the next player a different player number.

Cheers

Doug Wilson

more ▼

answered Nov 03 '14 at 07:24 PM

avatar image Kapos Nov 03 '14 at 08:05 PM

Hi Doug, thanks for the reply. PlayerNum is a variable I created in MyCharacter, and is currently doing nothing. This shouldn't have an affect on anything, should it? Also, previously I had the loop index plugged into PlayerNum and things still weren't working. Since I figured PlayerNum has no impact I removed this connection for the screenshot to reduce spaghetti clutter.

avatar image Doug E ♦♦ STAFF Nov 12 '14 at 08:09 PM

Hey Kapos-

The setup in your screenshot did work for me, however after clicking the play in editor button I was only able to move around using the second game pad after clicking in the viewport window.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question