Object visibility in Multiplayer

Hi,

While creating some working multiplayer shooter game I came up with a problem where I don’t know where to start.

I wanted to provide some specific meshes which should only be visible to a group of players in the game. The other players in the multiplayer game should not see theses meshes. Instead they have their own meshes which are only visible to them…

I thought about hiding meshes by the use of post processing, but post processing blendables only have some emissive input and no possibility to make something completly translucent. Or am I wrong? If yes I would use the custom stencil and some blendables per player type to hide/show the objects.

Further more there could be the possibility to use “Only owner see” but then I have to create the meshes for every single player and set these as the owner of the specific object. This would be some overhead.

Is there some easy solution to achieve this? I’m using ue4 now for almost 1,5 years but I can’t remember if I have ever seen some similar functionality.

Thanks for your help.

It is me again :slight_smile:
I found a solution by spawning the suiting meshes only on the owning client.
I call some custom event with “owning client” replication (blueprint) from the server (the one which has the authority).
When spawning the actor on the client I add the owner to the PlayerController.

For every trying around with this solution:
I wasn’t sure when to call the “owning client” custom event. First I called it on the BeginPlay node but this seemed to be to early (because of owner relationships). In the tick event it worked because there the owners are set already.

hi…i am interested at your work for my multiplayer game. Can you explain well what do you mean for " i add the owner to the player controller?? do you mean set owner only see? Sorry for my bad english and sorry for my question, but i am stopped in this point. thank you so much. if possible you can posted a screen with this specific function… :slight_smile:

Wow. you are a genius. you have find a nice solution… my case is different but is analog problem, because i want that the player name on head of single player is visible only the same team but no see for other team players. i am searching of adapt your solution for my case. thank you your very helpful, i hope help to you soon.

My question: Player name see only owner team - Multiplayer & Networking - Epic Developer Community Forums

Hi streusu.
Ok. I’ll try to explain these things.

I’ve created a team based shooter with starting areas for every single team. When you step into the starting zone of the enemy, you will die. This is done with damage volumes.

To mark these areas in the level I created some translucent meshes (double sided textures) with some kind of “stopping signs”. These should only be shown to the enemy team and not to the team which owns this specific base.

The level designer now has some “marker templates”. These templates can be placed in a level and they can be assigned to some specific team. At the location of these marker templates, the templates will be created dynamically during the game.

In the screenshot you can see the creation process. This is perhaps not the best solution but it is mine. :slight_smile:

The most important thing is that the event is running on the owning client and that the markers themselves are NOT replicated. When I now create them on the owning client they only exist there!

The first step is now to check if the markers have been already created. If no the process starts.
Because of initialization issues (and the possibility to switch the teams during game) all existing markers for this player are destroyed.

After that, all marker templates (the objects which can be set in the level by the level designer) are searched with GetAllActorsOfClass.

For each marker template it is checked if the owning client has the correct team and if he should see this specific marker (marker at the base of team 1 have the variable “TeamWhichSeesMarker” set to 2).

If the player should see the marker, it is spawned and the owner is set to the PlayerController actor/class of the owning client. Furthermore the marker is appended to the list of markers for this player.

At the end the flag that the markers have been created, is set to true.
If the player now switches the team this flag is deleted and the process starts again.

Here you can see some screenshot of a marker from my game prototype.

Oo. Didn’t answer directly to your question. Don’t know if you get some notification. So I add this message, too. :slight_smile:

I think you should use some other approach for HUD elements floating over the head.
My approach shows real objects in the 3d world but what you want is more a HUD element.

I created something similar to show healthbar above the heads of the team members.

  • Create a 3d widget

  • Add a text element to the 3d widget

  • Under details, bind the text element to a function in which you retriev the name of the player

  • Bind the visibility to a function. This function returns “hidden” when the current player (get player pawn) is not in the same team like the player of the widget, and “visible” if they are in the same team

  • Go to the character blueprint and add the 3d widget to it (in UE4.10 this feature is experimental, don’t know how it is in 4.11)

  • Set the widgets space attribute in the character blueprint to “screen” so that it is always faced towards the player

I hope I haven’t forgotten something. :slight_smile: Have fun with it!

You can see some example of my hud above a team member in the following screenshot:

Hello HAF-Blade . i want trying this solution but i think that is very good. i don t know can i thank you for your help…my player name is set like a player info( text render component), maybe this is the problem. thank you so much, if i can help you , you can asking me when do you want. See you soon :slight_smile: