How do you place APlayerCharacter onto APlayerStart and take control?

So the last problem is the way i’m currently dealing with axis bindings.

I ended up having to place the axis bindings back into my ABasePlayer, as it just wasn’t working inside the controller… my mistake i’m sure…

The issue is now, that the ABasePlayer has no idea of which player number it is and thus which axis bindings to use (I have labelled mine Player0MoveRight, Player1MoveRight etc.).

There were 2 choices, I’d love the answer to both if ya know what’s wrong:

Choice 1:

I add a property to the ABasePlayer, populate it in my LoadPlayers loop with the index of the current loop.

The problem is when the SetupPlayerInputComponent is called, that property is NULL again? If it wouldn’t nullify, this would be my preferred way of doing it.

Choice 2:

I find a function that returns the current players number, is there a function for this?

This is where the code is supposed to be:


void ABasePlayer::SetupPlayerInputComponent( class UInputComponent* InputComponent )
{
	int32 playerNumber = // A function that returns the player number
	
	FString axisName = FString::Printf( TEXT( "Player%dMoveRight" ), playerNumber );
	InputComponent->BindAxis( FName( *axisName ), this, &ATemplatePlatformerCharacter::MoveRight );
}

When I meant this is the call chain you’re looking for, I was saying these functions are already calling each other in that order… By calling everything yourself, you’re doing a lot of redundant work and reinitialization, and I wouldn’t be surprised if that was somehow resetting your input component.

@anonymous_user_dd7d789e - Do you want me to have *** with you, because that’s how you get me to have *** with you.

IT’S WORKINGGGGGGGGG! LOLLLLLLLLLL… The only thing i was missing was the RestartPlayer…

MY END LOOP IS LIKE SO SEXYYY WEXTYYpoie jkfpo;jkaw orawe g’iojaweigo;jae;igojreg


void AGeneralGameMode::LoadPlayers()
{
	if( MaxPlayerCount )
	{
		UWorld* currentWorld = GetWorld();

		UGameInstance* gameInstance = currentWorld->GetGameInstance();
		UGameViewportClient* gameViewport = currentWorld->GetGameViewport();

		// Remove split screen because I want a 2D game
		gameViewport->SetDisableSplitscreenOverride( true );

		for( int32 a = 0; a < MaxPlayerCount; a++ )
		{
			ULocalPlayer* localPlayer;

			if( a == 0 )
			{
				localPlayer = gameInstance->GetFirstGamePlayer();
			}
			else
			{
				FString createLocalPlayerError;
				localPlayer = gameInstance->CreateLocalPlayer( a, createLocalPlayerError, true );
			}

			RestartPlayer( localPlayer->PlayerController );

			//playerController->SetUpInput( playerActor, a );
		}
	}
}

Look at that ***, pure ******. Woop woop. Thank you thank you!

That’s great to hear! :slight_smile:

Yeah, the engine’s built-in code for player management, session management, etc. is made massively complicated by the needs for networking and all that jazz. For our game, I had to dig around quite a bit just to figure out a way to delay starting the game until some more processing was done. In the end, the solution I opted for it was pretty simple (override ReadyToStartMatch() in our game mode and have that return false until extra processing is finished), but I was floundering for a while until I arrived at that working solution.

Very glad you managed to get it working! Making the network player/session code MUCH simpler to use is very high on our priority list, we can see it causes lots of confusion for people. If you have any specific thoughts on how we should tackle that, we would be very interested :slight_smile:

JamesG I’m going to think about what i would have expected to see that would have taken the ball ache away from this process… and i’ll report back.

Just as an initial note, I always end up finding a blue print way of doing things in your documentation, but sometimes the C++ part is so hard to find.

For example, if i take a look at this documentation:

http://laravel.com/docs/4.2/quick

Quick start gives you the keywords that you might wanna search for… cool,

But then if you go into specific areas, it’s example after example… covering lots of different angles, making you more confident you get what’s going on:

http://laravel.com/docs/4.2/responses


I wonder if having an article called:

“Setting up 2 players locally and assigning a gamepad/keyboard keys to control them.”

And then an example bit of code would be useful.


As i say, i’ll go and write what i’d imagine would be helpful, i’ll also write what i had assumed would be how it would work, and i hope that will help you get a gist of what i had issues with.


Development is all about making choices, but making the right choice or a sensible choice is so difficult when you don’t know how some of the paths will affect you (especially in frameworks). Removing some of that choice or explaining the typical case scenarios to remove that fear from committing to a choice, would really help too.


Lol this is starting to feel patronising so my apologies, i’ll get back to you man! :D:D:D:D:D:D


Sorry for the long post, here’s a potato:

03085543-87de-47ab-a4eb-58e7e39d022e-620x372.jpeg

Did you finish this?