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"

PostProcess Outline PB in Multiplayer Game (C++)

Hi ,

I am develloping a multiplayer game, and i am stuck with something: I have implemented an outline around object that player are seing with a PostProcessVolume (Unbound, and with a material blendable).

My problem is that this work only for the last client connected to my game, other client can use my usable object, but are not seeing the outline effects.

alt text

To the left, outline is working (client 3 is the last client), to the right, player see the object (I can interact with it), but the outline effects doesn't work.

This is my tick function:

 void AMyCharacter::Tick(float DeltaTime)
     AUsableItem* itemSeen = GetItemFocus();
     static AUsableItem* oldFocus = NULL;
     oldFocus = ApplyPostProcessing(itemSeen, oldFocus);

My GetItemFocus :

 AUsableItem* AMyCharacter::GetItemFocus()
     // Attempt to use Raycasts to view an object and echo it back
     FVector CameraLocation;
     FRotator CameraRotation;
     // Fill CameraLocation, CameraRotation to there values
     if (Controller != nullptr)
         Controller->GetPlayerViewPoint(CameraLocation, CameraRotation);
         GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, TEXT("Null Pointer"));
         return nullptr;
         // build the start, end and direction for the trace line.
     const FVector StartTrace = CameraLocation;
     const FVector Direction = CameraRotation.Vector();
     const FVector EndTrace = StartTrace + (Direction * InteractionDistance);
     //DrawDebugLine(GetWorld(), EndTrace, StartTrace, FColor::Red, true);
     //set some parameters for the line we're going to draw.
     FCollisionQueryParams TraceParams(FName(TEXT("Line Aim Collision")), true, this);
     TraceParams.bTraceAsyncScene = true;
     TraceParams.bReturnPhysicalMaterial = true;
     //draw the line and get back whatever we were looking at
     FHitResult Hit(ForceInit);
     GetWorld()->LineTraceSingleByChannel(Hit, StartTrace, EndTrace, COLLISION_VIEW, TraceParams);
     return Cast<AUsableItem>(Hit.GetActor());

And My ApplyPostProcessing:

 AUsableItem* AMyCharacter::ApplyPostProcessing(AUsableItem* itemSeen, AUsableItem* oldFocus) {
     if (itemSeen) {
         //GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, TEXT("Item Seen"));
         // An item is currently being looked at
         if (itemSeen == oldFocus || oldFocus == NULL) {
             //The item being looked at is the same as the one on the last tick
             UStaticMeshComponent* mesh = itemSeen->Mesh;
             //GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, FString::SanitizeFloat(GetDistanceTo(itemSeen)));
         else if (oldFocus != NULL) {
             // An item is being looked at and the old focus was not null (and not the same as the one on the last tick)
             UStaticMeshComponent* mesh = itemSeen->Mesh;
             UStaticMeshComponent* oldMesh = oldFocus->Mesh;
         return oldFocus = itemSeen;
     else {
         // No item currectly being looked at
         if (oldFocus != NULL) {
             //An item was looked at last tick but isn't being looked at anymore
             UStaticMeshComponent* mesh = oldFocus->Mesh;
         return oldFocus = NULL;

Before that I had some problems with Controller (it returned null pointers), I have set a custom PlayerController, GameMode, and GameState, So Controller seems to be correctly assigned (I haven't null pointer for Controller anymore) I think there is something that I don't understand, but i don't know what , any help would be appreciated .

Thanks, Charlie

Product Version: UE 4.10
more ▼

asked Feb 26 '16 at 12:09 AM in C++ Programming

avatar image

21 1 2 8

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

1 answer: sort voted first

Ok , this was just stupid, the problem was in the tick function:

 static AUsableItem* oldFocus = NULL;

It can't work for a multiplayer game, the pointer to oldFocus must be stored in an attribute of the ACharcatere (declared in the .h file). remove this line and it works.

more ▼

answered Feb 28 '16 at 11:05 PM

avatar image

21 1 2 8

(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