#trying to SetActive a gameobject to everyone

3 messages · Page 1 of 1 (latest)

spice wagon
#

can someone send a simple example on how to do it correctly (im not sure how to use ObserverRpc and events)
im still new to multiplayer development thanks for support ❤️

vivid dawn
#
[ObserverRpc(BufferLast=true, RunLocally=true)] void ObserverSetActive(bool isActive) {
  gameObject.SetActive(isActive);
}

Basically like this and then you can call it from the Server side, if its from client side, you need to do a ServerRpc before and in the ServerRpc you call then the ObserverRpc.
RunLocally make sure that the server also execute this, so you dont need duplicated logic. BufferLast make sure, that the recent changes get transfered to new observer clients

spice wagon
#

@vivid dawn thanks brother thats very helpful