Make player non-existent to specific player

Hello !

I started to study UE4, with Udemy’s course, and I have a question.
I want to make a little game prootype, with an “uncommon” mechanic. Let me explain.

For example, the round start with 4 players, noted player 1, 2, 3 and 4. At some point, on a specific action, player 1 and player 2 will not be able to see each other anymore.

Player 1 still see player 3 and 4.
Player 2 still see player 3 and 4.
Player 3 still see player 1, 2 and 4.
Player 4 still see player 1, 2 and 3.

And by don’t “see” it anymore, I also mean, no interaction at all. Player 1 and 2 don’t see each other, and can’t collide themselves.

Where do I need to look to find the proper knowledge ? Is it a matter of replication ? Conditional replication ? Relevancy ? Just a matter of “hidden” and “collision” property ?

The only thing I’m (almost) sure is I have to keep an array of boolean for “players visibility” in the GameMode class.

Thanks in advance.

It’s my first question on UE4 on this forum, I hope it’s not stupid.

This could be handled by an event invoked by the server on the players in question. Following your example:
Server: Player1->SetPlayerVisibility(Player2, false);
Server: Player2->SetPlayerVisibility(Player1, false);

In the definition I would simply the Player as invisible and disable its collision response to me.
If you want to get technical micro-optimize you can also disable replication of that player to the one who can’t see him.

You could store the “state” of visibilities in the GameMode class, sure, but it doesn’t need to be replicated.
That is unless you want Player 3 & 4 to know that Player 1 & 2 can’t see eachother.

Thanks for the response MPalacios !

I did some research, and I would like to know if I have found the good methods to do this in my “SetPlayerVisibility”.

I imagine “SetPlayerVisibility” will be a method of a child class of “MyPlayerController”, a child class of APlayerController.

To disable visibility between those two players, I will use the method APlayerController::HiddenActors
To disable collision between those two players, I will use the APawn of the PlayerController, and use the method APawn::MoveIgnoreActorAdd

And for the network optimization, I have read the “UE4 Network Compendium” by Cedric Neukirchen, and the “relevancy” looks like the thing I need to understand properly to don’t send useless data to clients. Maybe I should override AActor::IsNetRelevantFor().

Am I on the right track ?

And yes, you are right, I don’t really need to keep track of the “visibilities states”. As soon as I properly disable visibility and collision, I don’t need to keep track of them, even less replicate them.

Thanks in advance.