Get two players in a game (single player)

Hello,

I am trying to get two players in a game where the player can control two separate characters on the same keyboard (similar to the game Two Brothers). I am using the basic C++ side scroller project and I am trying to make a copy of the character to make another one spawn. I tried adding another Player start, but I don’t know how to link that with a second player. I am not trying to do a multiplayer game so I am unsure how to have another character in the game. Any help would be great! Thanks!

Search API reference more ;]

UGameplayStatic::CreatePlayer(GetWorld(),-1,true);

The lest bool decides whatever to spawn and automaticlly posses pawn, if you do false you will need to do the setup for yourself. This function also returns APlayerController of new player so imidietly you can do operations on him once you call this function

Hi Shadowriver, I found that API referance, but I wasn’t sure how to use it. Would I place it in the initialize of the character class and how can I give the second player different inputs for him? Can I use a tag in the input and then check that tag for each character?
Code attachedlink text

Things like adding player is part of game rules, so you should have it in AGameMode.

Think a little, when you want add player and plcae this function in right moment

Hi Shadowriver, thank you, but I am still a little confused. I placed it in the game mode area and removed the other code, but it is still crashing. I am still new to UE4 (came from unity) so I am confused by the C++ and the lack of sleep from doing a game jam is not helping lol.
Here is the new code: link text

World instance dont exist on constractor so GetWorld return null, you should call it on BeginPlay().

Never place game code in constructor, only place default varables sets there, engine calls constructor not only during game to check default varables, so game code there wont work and will crash the game

Ah okay thank you! I placed it inside its own begin play function and that makes a lot of sense. Now I notice that this creates a split screen effect. Is there a way to make them both on one screen? And is there a way to change the second players controls?

You can disable split screen in project settings as remeber, not sure about controls, you can create 2nd set of bindings and make 2nd playercontroller bind things diffrently

okay thank you so much! I have fixed the splitscreen and trying to make the key binds which I think I got, now I just need to get them to bind to the second player controller and I will be all set. If you know the specific, let me know but thank you!