x


Can state synchronisation sync complete Components, or just 1 var at a time?

Situation:

I am currently dealing with a network game where the player has several statistics like how many bombs he still has, how many lives, etc. Can I synchronize this complete 'Player' Component with all its variables via State Synchronisation?

Research:

The documentation seems to be unclear on this. From http://unity3d.com/support/documentation/Components/net-StateSynchronization.html

Unity can synchronize Transform, Animation, Rigidbody and MonoBehaviour components.

  • Transforms are serialized by storing position, rotation and scale. Parenting information is not transferred over the network.

  • Animation serializes each running animation state, that is the time, weight, speed and enabled properties.

  • Rigidbody serializes position, rotation, velocity and angular velocity.

  • Scripts (MonoBehaviours) call the function OnSerializeNetworkView().

However, BitStream.Serialize(), used within OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info), only handles a certain amount of datatypes (int, string, Vector3 etc).

Question:

Am I allowed to just grab a component and synchronize this AS A WHOLE? (so in my case ALL the public vars hanging within my 'Player' Component)

If not, how do I utilize OnSerializeNetworkView() in such a way that if I send 'available bombs' for instance from the server, the client KNOWS it's receiving 'available bombs' and not 'number of lives' for instance?

Thanks in advance :)

more ▼

asked Apr 11 '12 at 12:56 PM

Jordii gravatar image

Jordii
158 9 11 17

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x178
x10
x3

asked: Apr 11 '12 at 12:56 PM

Seen: 425 times

Last Updated: Apr 11 '12 at 12:56 PM