Exemple #1
0
        void InvokeApplyTransform(ulong clientId, Vector3 position, Quaternion rotation, string channelName)
        {
            using (PooledBitStream stream = PooledBitStream.Get())
            {
                using (PooledBitWriter writer = PooledBitWriter.Get(stream))
                {
                    if (TransformTypeToSync == TransformType.Transform2D)
                    {
                        if (SyncPosition && SyncRotation)
                        {
                            writer.WriteVector2Packed(position);
                            writer.WriteSinglePacked(rotation.eulerAngles.z);
                        }
                        else if (SyncPosition)
                        {
                            writer.WriteVector2Packed(position);
                        }
                        else if (SyncRotation)
                        {
                            writer.WriteSinglePacked(rotation.eulerAngles.z);
                        }

                        InvokeClientRpcOnClientPerformance("ApplyTransform2D", clientId, stream, channelName, Security.SecuritySendFlags.None);
                    }
                    else if (TransformTypeToSync == TransformType.Transform3D)
                    {
                        if (SyncPosition && SyncRotation)
                        {
                            writer.WriteVector3Packed(position);
                            if (FullRotation)
                            {
                                writer.WriteVector3Packed(rotation.eulerAngles);
                            }
                            else
                            {
                                writer.WriteSingle(rotation.eulerAngles.y);
                            }
                        }
                        else if (SyncPosition)
                        {
                            writer.WriteVector3Packed(position);
                        }
                        else if (SyncRotation)
                        {
                            if (FullRotation)
                            {
                                writer.WriteVector3Packed(rotation.eulerAngles);
                            }
                            else
                            {
                                writer.WriteSingle(rotation.eulerAngles.y);
                            }
                        }

                        InvokeClientRpcOnClientPerformance("ApplyTransform", clientId, stream, channelName, Security.SecuritySendFlags.None);
                    }
                }
            }
        }
Exemple #2
0
 public void Serialize(PooledBitWriter writer)
 {
     writer.WriteVector2(Position);
     writer.WriteSingle(Angle);
 }
 public void Serialize(PooledBitWriter writer)
 {
     writer.WriteSingle(Height);
 }