In my game I overrode the “spawn default pawn for” using blueprints to spawn the clients’ selected characters then call a c++ function to posses their activate character and hide the inactive characters. It is working as expected in the PIE, but in the build version of the game I’m having issues.
void ABrawlersOfDualityPlayerController::TeamInit()
{
ServerTeamInit();
}
void ABrawlersOfDualityPlayerController::ServerTeamInit_Implementation()
{
if(TeamCharacters.Num() < 3) return;
TeamCharacters[0]->SetOwner(this);
TeamCharacters[1]->SetOwner(this);
TeamCharacters[2]->SetOwner(this);
TeamCharacters[0]->Controller = this;
TeamCharacters[1]->Controller = this;
TeamCharacters[2]->Controller = this;
TeamCharacters[0]->BrawlerPlayerController = this;
TeamCharacters[1]->BrawlerPlayerController = this;
TeamCharacters[2]->BrawlerPlayerController = this;
TeamCharacters[1]->ServerSwapOut();
TeamCharacters[2]->ServerSwapOut();
GetCharacter();
Possess(TeamCharacters[0]);
bTeamInitialized = true;
}
In the build version of my game the client player is unable to move the character, but the character can still attack and change animation states. The attacks are bound like this in the character class:
PlayerInputComponent->BindAction(“LightAttack”, IE_Released, this, &ABasePlayableCharacter::LightAttackButtonReleased);
While the movement is bound like this:
PlayerInputComponent->BindAxis(“MoveForward”, this, &ABasePlayableCharacter::MoveForward);
and can be called from the player controller for mouse and touch input in the playertick
PlayerTick(float DeltaTime)
{
Super::PlayerTick(DeltaTime);
if(bInputPressed)
{
FollowTime += DeltaTime;
// Look for the touch location
FVector HitLocation = FVector::ZeroVector;
FHitResult Hit;
if(bIsTouch)
{
GetHitResultUnderFinger(ETouchIndex::Touch1, ECC_Visibility, true, Hit);
}
else
{
GetHitResultUnderCursor(ECC_Visibility, true, Hit);
}
HitLocation = Hit.Location;
// Direct the Pawn towards that location
if(bTeamInitialized && TeamCharacters.Num() > 0)
{
if (GEngine)
{
GEngine->AddOnScreenDebugMessage(-1, 0.016f,FColor::Red,FString(TEXT("Calling move forward")));
}
FVector WorldDirection = (HitLocation - TeamCharacters[0]->GetActorLocation()).GetSafeNormal();
TeamCharacters[0]->MoveForward((float) WorldDirection.X);
TeamCharacters[0]->MoveRight((float) WorldDirection.Y);
}
}
else
{
FollowTime = 0.f;
}
}
I need help figuring out how to solve this issue, and if there is a faster way than packaging the build and downloading it on another computer to test it.
Thanks!