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"

AnswerHub Maintenance

Background maintenance is scheduled to occur between 9 - 11am EDT on Tuesday, May 21. Site operation may be slower than normal during this time and a brief interruption in operation may be observed

Multiple playercontrollers using keyboard

Hi, I'm working on a 2 player(local) game.

My second player is created using GEngine->GameViewport->CreatePlayer(1, ....); in a custom GameMode. The second player spawns correctly, but I cannot control it.

I have a PlayerController in blueprint that handles keyboard input to move the pawn created by the player. Both players created use the same type of PlayerController, but the keyboard events fire only on the first player.

I have tried changing to CreatePlayer(0, ....). All my characters and controllers have Auto Receive Input disabled, although I have tried all possible values for them.

I have spent hours searching and trying to figure out how to control both players with the keyboard. I want to use WASD for one player and the arrow keys for the second.

Any help would be greatly appreciated, thank you!

Product Version: Not Selected
Tags:
more ▼

asked Apr 26 '14 at 03:16 AM in Using UE4

avatar image

malo
66 2 4 8

(comments are locked)
10|2000 characters needed characters left

5 answers: sort voted first

The keyboard input is by default allocated to go only to player 0. To change this you would need to subclass UGameViewportClient and override the behavior of InputKey

I'll make a note to consider whether to add some easier way of redirecting a given device (in the case of gamepads) or to allow sharing of the input device for the keyboard like in this case.

more ▼

answered Apr 26 '14 at 11:01 AM

avatar image

Marc Audy STAFF
2.2k 42 35 95

avatar image Eduard Gotwig Dec 30 '14 at 08:49 PM

IMHO this is a bug. Any idea if this will get fixed in the future?

(comments are locked)
10|2000 characters needed characters left

I am currently working on a Fighting Game and I have local players using one keyboard quite easily.

Here is how I do it;

Create Player Character in Game Mode with new controller. Then in first player controller, I cast to the second controller to make things happen for second character. So it looks like 2 people using 1 keyboard, while internally both players are using the first player controller.

But yeah, a new system for local players should be implemented.

more ▼

answered May 24 '15 at 03:39 AM

avatar image

Achilleon
772 38 33 70

(comments are locked)
10|2000 characters needed characters left

This really should be changeable in the editor. Please add my vote for fixing this bug.

more ▼

answered May 22 '15 at 06:40 PM

avatar image

WACOMalt
101 4 8 16

(comments are locked)
10|2000 characters needed characters left

Add my vote to this, it would be an extremely useful feature, I understand there are work around but it would make sense to have a more proficient method for this.

more ▼

answered Dec 18 '15 at 09:09 PM

avatar image

The Cheese Dragon
191 8 11 34

(comments are locked)
10|2000 characters needed characters left

Please Achillon! Send screenshots of your solution for two players.

more ▼

answered Nov 23 '15 at 07:18 PM

avatar image

InLove4
1 1 2 3

avatar image Sargas Evigmae May 03 '16 at 06:37 AM

it's actually super simple. he manually set the input in the game input settings, but "duplicated", so once for wasd and once for, say, the arrows. The player controller (0) then sends the part of the input that he wants to be of player 2 to the player controller (1) using "cast to". this has to be done this way since the keyboards only sends input to player controller (0)

(comments are locked)
10|2000 characters needed characters left
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