Why do we need to call SetVisibility on the client?

Hi,
Originally when I saw that:
Mesh->SetVisibility(!IsCollected);
was being called for both the server and the client, I thought maybe it is because visibility doesn’t get replicated.
However, if I move this code into the “if (HasAuthority())” section so that only the server executes it, I still see it disappearing on all the clients.
Is it not sufficient to just call SetVisibility on the Server and let that replicate through or am I missing something?
Thanks!

I actually did wonder about this and I think you are right, you can just set it on the server and this will replicate to the client. This would make the solution neater.

Thanks for confirming. I guess one could argue that if you execute it on the client as well… it happens immediately and doesn’t need to wait for the server to tell it to do so. There will be less of a lag under network congestion but it will usually not be noticeable.

1 Like

That also makes sense and probably why this was done this way in the course materials. The delay is maximum 1 second so not too bad.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms