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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Can't move client

I've been extending the ShooterGame template with a new GameMode (not based on the AShooterGameMode class, but on AGameMode). In single player my game mode works as inteded, so I decided to try and add multiplayer. My first problem is that the client can't move and can't see movement of other players / AI (bots appear static from the client's perspective). Also, his camera (3rd person camera) is targetting him from the right side rather than from the back. He can rotate on the Z axis and shoot. Server works fine.

Also, changing the GameMode to any of the ones provided in the ShooterGame template makes the multiplayer work, so my problem must be on the GameMode / GameState / PlayerState (I'm using the ShooterPlayerController provided).

I initially thought that this might be the problem:

 void AWaveGameMode::BeginPlay() {
     Super::BeginPlay();
     Super::HandleMatchHasStarted();
 
     for (FConstPlayerControllerIterator Iterator = GetWorld()->GetPlayerControllerIterator(); Iterator; ++Iterator)
     {
         APlayerController* PlayerController = *Iterator;
         if (PlayerController && PlayerController->IsLocalPlayerController()) {
             AShooterHUD* ShooterHUD = Cast<AShooterHUD>(PlayerController->GetHUD());
             if (ShooterHUD) {
                 ShooterHUD->SetMatchState(EShooterMatchState::Playing);
             }
         }
     }
 
     TArray<AActor*> Spawns;
     UGameplayStatics::GetAllActorsOfClass(GetWorld(), APlayerStart::StaticClass(), Spawns);
     for (AActor* Spawn : Spawns) {
         if (Spawn->ActorHasTag(SpawnTag)) {
             AISpawnPoints.Add(Spawn);
         }
     }
 }
 

As the Client might not be getting the Playingmatch state, so I added this piece of code:

 void AWaveGameMode::PostLogin(APlayerController* NewPlayer)
 {
     Super::PostLogin(NewPlayer);
 
     // update spectator location for client
     AShooterPlayerController* NewPC = Cast<AShooterPlayerController>(NewPlayer);
     if (NewPC && NewPC->GetPawn() == NULL)
     {
         NewPC->ClientSetSpectatorCamera(NewPC->GetSpawnLocation(), NewPC->GetControlRotation());
     }
 
     // notify new player if match is already in progress
     if (NewPC && IsMatchInProgress())
     {
         NewPC->ClientGameStarted();
         NewPC->ClientStartOnlineGame();
     }
 }

But didn't work. Only spawned the crosshair on the client, but it still can't move / see players moving.

I also tried adding this snippet to AShooterCharacter::Tick to help debug the problem:

     AShooterPlayerController* MyPC = Cast<AShooterPlayerController>(Controller);
 
     if (IsPlayerControlled()) {
         if (MyPC && MyPC->GetShooterHUD() && MyPC->GetShooterHUD()->GetMatchState() == EShooterMatchState::Playing) {
             GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, "playing");
         }
         else {
             if (MyPC) {
                 if (!MyPC->GetHUD()) {
                     GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, "Couldnt find hud");
                 }
             }
             else {
                 GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, "Couldn't find player controller");
             }
             GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, "not playing");
         }
     }
 

And for Player 2 (ShooterController_1) I get the not playing and couldnt find hud messages. So I'm kind of lost here =\

How can I further debug / resolve what my problem is?

Product Version: UE 4.14
Tags:
more ▼

asked Mar 23 '17 at 03:06 PM in C++ Programming

avatar image

FernandoDoming
41 3 5 9

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Turns out I was using AGameModeStateBase instead of AGameMode as a parent. Changing class parent solved the issue (don't really know why, I'm guessing AGameMode has additional initialization, but not sure).

more ▼

answered Mar 29 '17 at 12:15 AM

avatar image

FernandoDoming
41 3 5 9

avatar image hdelattre Jun 15 '17 at 08:27 AM

You really saved me with this post, I've been looking for a solution for 3 days. I was using AGameMode with AGameStateBase and I fixed it by switching to AGameState. I found out that the base versions of AGameMode/AGameState are not usable with the non base versions, so I'm not sure if the issue is due to that incompatibility or if AGameStateBase just isn't set up to replicate the game start to clients. Either way, this change resolved my client issues so thank you very much.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
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