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"

Multicast function not running on clients

The function is on a PlayerController. It is not being called on clients, but is being called on the authority.

Declaration:

 UFUNCTION( NetMulticast, Reliable )
 void MulticastSetNewViewTarget( APawn* ViewPawn );
 void MulticastSetNewViewTarget_Implementation( APawn* ViewPawn );


Definition:

 void AHookCharacterPlayerController::MulticastSetNewViewTarget_Implementation( APawn* ViewPawn )
 {
         if( Role < ROLE_Authority )
         {
             GEngine->AddOnScreenDebugMessage( -1, 10.0f, FColor::Red, TEXT( "client" ) );
         }
         SetViewTarget( ViewPawn );
 }


Call:

 HookCharacter = GetWorld()->SpawnActor<AHookCharacter>( HookCharacterClass );
 MulticastSetNewViewTarget( HookCharacter );





Nothing is printed. bReplicates is set to true.

Product Version: Not Selected
Tags:
more ▼

asked Apr 08 '15 at 04:45 PM in C++ Programming

avatar image

Bonnnnnn
135 8 14 23

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Unfortunatly I have found AddOnScreenDebugMessage method for testing if your network functions are being called to be useless. A better method is to add a log that tells you if the function was called on the client or the server and print a message. My general function is declared in MyGame.h

MyGame.h

 DECLARE_LOG_CATEGORY_EXTERN(MyGameLog, Log, All);

 void WriteMyGameLog(FString Msg);

MyGame.cpp

 void WriteMyGameLog(FString Msg)
 {
     if (GEngine)
     {
         if (GEngine->GetNetMode(GetWorld()) == ENetMode::NM_Client)
         {
                     // set this one to log so it shows grey
             UE_LOG(MyGameLog, Log, TEXT("CLIENT - %s"), *Msg);
         }
         else if (GEngine->GetNetMode(GetWorld()) == ENetMode::NM_ListenServer || GEngine->GetNetMode(GetWorld()) == ENetMode::NM_DedicatedServer)
         {
                     // set this one to error so it shows red.
             UE_LOG(MyGameLog, Error, TEXT("SERVER - %s"), *Msg);
         }
     }
 }

Now because this is declared in your MyGame.h it is included in all your C++ files and can be called to write to your game log. You can see the output in the editor under the Output Log found under the Window Drop Down menu (may be under Window -> Developer -> Output Log) or (Window -> Output Log). Basically open this up, run your game, and look for your log entries and they will correctly tell you if the message is on the server or client.

more ▼

answered Sep 09 '15 at 06:37 PM

avatar image

ArcainOne
454 32 25 55

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