#How can i send clients a variable that is calculated and updated in Server?

1 messages · Page 1 of 1 (latest)

mystic skiff
#

I'm making a game that has a server running that is responsible to manage the game rules, and Clients only receive events to update their contents. I need to implement a timing variable that changes every frame and needs to be calculated in the server. I don't want to send them as events because they need to be updated every frame. I have searched the contents of SyncVar, but i don't know how they can be used in this case. The variable should be maintained and updated on the server only. Clients need only the read the variable, but not modify them. The variable is not owned by neither client, and instead the server itself

acoustic moat
mystic skiff
#

But what if in the future i need a variable that is not based on time?

acoustic moat
#

SyncVars would be fine for that

mystic skiff
#

but aren't SyncVars attached to a client?

#

in my game i don't use NetworkBehaviours

#

all communications are made via RegisterHandle

#

and how can a server edit a variable that exists only in a component in the client project?

acoustic moat
#

Make a networked scene object with SyncVars and spawn player object for each client and everything gets a lot easier. You can even set the player object so it's only spawned on the owner client, and not any of the others, if that suits your needs.