Day and Night cycle over the network.

In my game scene I have a Sky-box which works as a Day and Night cycle however it runs off of its own timer so when a player joins the scene latter than another player of course they are going to experience a different time of day than the other player because their timer is behind or ahead. So I created a timer server side but since the server is on a different Game Object it cannot receive RPC functions from the sky-box requesting the time.

To sum it all up i’m basically trying to have the sky-box’s time sync’d with the servers time which are to completely different objects.


Anyone got any clues on how I could achieve this?

Thanks.

So in the server script… you go… GameObject.Find(“Sky Dome”).transform.rotation = etc.
Just because the server is on a different object does not mean you can’t access other objects in the code. So create an rpc function that receives the correct rotation of the skybox from the server. Then the server, when a player connects, sends the rpc and the receiving client’s rpc function sets the skybox based off the information given.

You can serialize the rotation of the object by putting a networkView on the object. If you want it to be smooth, then you will need to do Quaternion.Slerp to do a spherical interpolation to the new rotation.

If you are going to smooth it out then you are going to want to serialize the variables yourself. You do not need to watch this entire video but it goes over how to serialize variables with a networkView: