Replicated Decals - The proper way

Hello everyone,

I am working on a networked project where my decals are an important part of my gameplay mechanic.
Let’s say we have a spell cast somewhere a decal is showing the affected area of this spell.

I’m questioning myself about the proper way to manage my decals.

What I am doing right now is that I spawn the decal on the server which replicates on the clients.
It’s actually not working well as the decal is showing on the clients but with no material loaded.

Questions:

  • Is it normal that my decal spawned on the server did not replicate the material used on the clients? (Material set with SetDecalMaterial(mat))
  • Is spawning a decal on the server side irrelevant and should always be spawned on the client side?

It might be an odd question, but a hint would be very appreciated.
Thank you

Decals aren’t usually replicated and aren’t really supposed to be most of the time, so it doesn’t surprise me that this doesn’t work. Decal Components don’t have any replicated properties so it seems reasonable that even if you replicate the component itself, the client would only know to create the component and do nothing else.

My suggestion would be instead of wasting actor channels on individual decals, just create a data structure you can replicate through some kind of manager actor, which will allow clients to create the decals themselves locally.

Usually however - impact effects and decals are all handled client-side (you don’t want to waste cycles on dedicated servers processing things that will never be rendered). Unless the Server is doing something the client doesn’t know about, it should be fine to create the decals client-side anyway when the spell impacts something on the client.

Hello TheJamsh,

Thank you for your reply.
I’m using this decal as an indicator of spell range that every connected player will be able to see.
So it’s very important for me that its position and state is accurate to all clients.

I will go with your suggestion.
Thank you very much.

Edit:

The weird part is that it is replicating everything except its material. For example, the scale is replicated properly.

For those who are interested in achieving this :

I managed to keep the decals persistent in the map using custom events with Replication :

The “RPC_Server_AddDecal” event replication run on server :

image

While the “RPC_AddDecal” event replication is multicasted :

image

Meaning the server run the first event (“RPC_Server_AddDecal”) of a client then he multicasts the creation of the client’s decal to all other clients through the second event (“RPC_AddDecal”) which makes the decal appear for all clients.

To keep the decal created by clients persistent, meaning it appears to a client that just joined the map of the server, The “BP_Decal” replication section needs to have the Replicates checkbox checked :

For those who want to copy-paste it, here is a link to it : Replication of a decal posted by anonymous | blueprintUE | PasteBin For Unreal Engine

To hesitate to respond if you have any questions

1 Like