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.

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)
{
	Super::Tick(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);
	}
	else
	{
		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;
			mesh->SetRenderCustomDepth(true);
			
			//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;
			mesh->SetRenderCustomDepth(true);

			UStaticMeshComponent* oldMesh = oldFocus->Mesh;
			oldMesh->SetRenderCustomDepth(false);
		}

		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;
			mesh->SetRenderCustomDepth(false);
		}

		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

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.