Why can't my client move after joining listen server?

Currently having a client be the server(listen server) hosting the game and allowing other clients to join but as of now the clients that join the server can’t move at all. Everything is set to replicate(movement, etc.) including the functions regarding the movement.

PlayerPawn.h

UFUNCTION(Server, Reliable)
		void MoveForward(float _value);
		void MoveForward_Implementation(float _value);

	UFUNCTION(Server, Reliable)
		void MoveRight(float _value);
		void MoveRight_Implementation(float _value);

	UFUNCTION(Server, Reliable)
		void MoveUp(float _value);
		void MoveUp_Implementation(float _value);

	UFUNCTION(Server, Reliable)
		void LookUp(float _value);
		void LookUp_Implementation(float _value);

	UFUNCTION(Server, Reliable)
		void Turn(float _value);
		void Turn_Implementation(float _value);

PlayerPawn.cpp

void APlayerPawn::MoveForward_Implementation(float _value)
{
	if ((Controller) && (_value != 0.0f))
	{
		FVector directionLocal = FRotationMatrix(GetControlRotation()).GetScaledAxis(EAxis::X);
		directionLocal = FVector(directionLocal.X, directionLocal.Y, 0.0f).GetSafeNormal();
		AddMovementInput(directionLocal, _value);
	}
}

void APlayerPawn::MoveRight_Implementation(float _value)
{
	if ((Controller) && (_value != 0.0f))
	{
		FVector directionLocal = FRotationMatrix(GetControlRotation()).GetScaledAxis(EAxis::Y);
		AddMovementInput(directionLocal, _value);
	}
}

void APlayerPawn::MoveUp_Implementation(float _value)
{
	if ((Controller) && (_value != 0.0f))
	{
		FVector directionLocal = FRotationMatrix(GetControlRotation()).GetScaledAxis(EAxis::Z);
		AddMovementInput(directionLocal.ZAxisVector, _value);
	}
}

void APlayerPawn::LookUp_Implementation(float _value)
{
	AddControllerPitchInput(_value * BaseLookUpRate * GetWorld()->GetDeltaSeconds());
}

void APlayerPawn::Turn_Implementation(float _value)
{
	AddControllerYawInput(_value * BaseTurnRate * GetWorld()->GetDeltaSeconds());
}

Any ideas?

Thanks in advance. :slight_smile:

Do you own the Pawn or is the server the owner?

You can be sure that the player controller is owned by the player but if the pawn is spawned on the server then it might own it.

Did you posses the pawn with your player controller during AGameMode::PostLogin ?

This is how I’m doing it now and it’s still not working:

The player start tags are set to 0 and 1 for the array indexes of AllConnectedControllers and the players spawn in but the client that joined the listen server(host) can’t move at all.

Here’s the movement implementation:

Pawn.h
Screenshot (271)

Pawn.cpp

Also the Server tag was also tried in the movement replication code and it still doesn’t work.

Did you tried this?

PlayerController->SetShowMouseCursor(false);
UWidgetBlueprintLibrary::SetInputMode_GameOnly(PlayerController, false);

Do you have the player input setup via SetupPlayerInputComponent?

Example:

void APlayerPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
	// Add Input Mapping Context
	if (APlayerController* PlayerController = Cast<APlayerController>(GetController()))
	{
		if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PlayerController->GetLocalPlayer()))
		{
			Subsystem->AddMappingContext(DefaultMappingContext, 0);
		}
	}
	
	// Set up action bindings
	if (UEnhancedInputComponent* EnhancedInputComponent = Cast<UEnhancedInputComponent>(PlayerInputComponent)) {
		
		// Jumping
		EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Started, this, &ACharacter::Jump);
		EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Completed, this, &ACharacter::StopJumping);

		// Moving
		EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &APlayerPawn::Move);

		// Looking
		EnhancedInputComponent->BindAction(LookAction, ETriggerEvent::Triggered, this, &APlayerPawn::Look);
	}
	else
	{
		UE_LOG(LogTemplateCharacter, Error, TEXT("'%s' Failed to find an Enhanced Input component! This template is built to use the Enhanced Input system. If you intend to use the legacy system, then you will need to update this C++ file."), *GetNameSafe(this));
	}
}