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"

Local MP: Second player created; how to control it?

Hello. I've set the level blueprint to create a second player a few seconds after game starts (so the first player can move away from Player Start, just a rudimentary temporary solution).

The issue is that the second player doesn't respond to user input, I have a X360 gamepad connected to the computer and, opposed to what I've read in an older thread, the gamepad doesn't automatically take control over the second player; the X360 gamepad just controls the first player, and the same for keyboard and mouse.

I've checked through a "Print String" function that Player Index 1 and PlayerController 1 do exist; another prove is that, in the graph section showed below (level blueprint), the second player part of the split screen effectively is set to a camera (and that requires PlayerController 1 to exist as you can see).

alt text

So what can I do to make the gamepad take control over the second player?

Product Version: Not Selected
Tags:
more ▼

asked Apr 12 '14 at 09:20 AM in Blueprint Scripting

avatar image

Albert Espín
967 80 97 358

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

3 answers: sort voted first

I've finally done it with a C++ function in my GameMode subclass that calls this:

 GEngine->GameViewport->CreatePlayer(1, Error, true);

Thanks to slayeruk for pointing it.

Both player are only controllable with two X360 gamepads in my case though. And at first the second player doesn't spawn because the first one is blocking the Player Start; a timer call in the C++ code or a more complex spawning system can be used to solve that.

more ▼

answered Apr 12 '14 at 10:03 PM

avatar image

Albert Espín
967 80 97 358

avatar image kevinirvani Aug 29 '14 at 12:26 AM

Is there a way to do this in blueprints?

avatar image Albert Espín Aug 29 '14 at 06:25 AM

If you mean calling the function, yes, I think at 4.2 or so Create Player was exposed to Bluperints.

avatar image MattWoelk Jul 12 '16 at 12:27 AM

Yup, here's an example:

blueprint node

avatar image oOo.DanBO.oOo Sep 20 '14 at 10:05 AM

Hm everytime i try to call this function is says its deprecated. I should use:

 CreateLocalPlayer(...) 
 // but when i try to
 GetWorld()->GetGameInstance()->... 
 // i cannot get any further with this call: pointer to incomplete class type... same with this call: 
 GetGameInstance()->

ok deprecated anyway... when i debug the game i get Unhandled exception at 0x00007FF88BCD4287 (UE4Editor-Bily-7441.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0x0000000000000000.

and this comes from

 FString something{ "hello" };
 GetWorld()->GetGameViewport()->CreatePlayer(1, something, true);

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

The first gamepad, the keyboard and the mouse seem to have the same internal controller id, which is 0. So you cannot easily control the first player with the mouse and the second using the first controller.

Creating a user via blueprints is done using "CreatePlayer" which can also simply be called in C++ with UGameplayStatics::CreatePlayer().

Marc

more ▼

answered Oct 23 '14 at 01:01 PM

avatar image

mkamradt
294 15 136 34

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

answered Mar 07 '17 at 03:53 AM

avatar image

youthnick
170 1 5 7

(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