- Home /
How do you Change Color or any variable of non-player object on both client and server in uNet
I am prototyping an RTS. I want certain buildings to be able to be "disabled" on both client and server and I want to show this by setting the meshrenderer material to a "disabled color", which of course is different than the enabled color. I thought I would be able to change this on both the server and client using a [Command] but I have had issues.
I know I have to use some combination of:
[SyncVar] Color buildingColor; [Command] UpdateColor() { //Set this buildings meshrenderer.material.color = color }
but I keep having trouble from the client side, the server/host computer can set the colors fine, but on the client, I keep getting ERROR: Trying to send message from object without Authority EVEN THOUGH LocalPlayerAuthority is checked on that very NetworkIdentity.
I continue to struggle understanding how to make this sort of State Change on a non-player object work, there is no documentation with this sort of example. I have had no trouble getting non-player objects to instantiate bullets clientside using [Command] but for some reason I cannot reproduce it again when changing state. Thank you.