本文整理汇总了C#中NetworkReader.ReadQuaternion方法的典型用法代码示例。如果您正苦于以下问题:C# NetworkReader.ReadQuaternion方法的具体用法?C# NetworkReader.ReadQuaternion怎么用?C# NetworkReader.ReadQuaternion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetworkReader
的用法示例。
在下文中一共展示了NetworkReader.ReadQuaternion方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnDeserialize
private CharacterState serverLastState; //SERVER: Store last state
#endregion Fields
#region Methods
/// <summary>
/// All Clients: Deserialize the state from network
/// </summary>
/// <param name="reader"></param>
/// <param name="initialState"></param>
public override void OnDeserialize(NetworkReader reader, bool initialState)
{
CharacterState state = new CharacterState();
state.state = reader.ReadInt32();
state.position = reader.ReadVector3();
state.rotation = reader.ReadQuaternion();
//Client: Received a new state for the local player, treat it as an ACK and do reconciliation
if (isLocalPlayer) {
SendMessage("ServerState", state, SendMessageOptions.DontRequireReceiver);
} else {
//Other Clients: Received a state, treat it like a new position snapshot from authority
if (initialState)
{
//Others Clients: First state, just snap to new position
transform.position = state.position;
transform.rotation = state.rotation;
}
else if (networkInterpolation != null)
{
//Others Clients: Interpolate between received positions
networkInterpolation.ReceiveState(state);
}
}
}
示例2: Deserialize
public override void Deserialize(NetworkReader reader)
{
this.netId = reader.ReadNetworkId();
this.assetId = reader.ReadNetworkHash128();
this.position = reader.ReadVector3();
this.payload = reader.ReadBytesAndSize();
uint num = 0x10;
if ((reader.Length - reader.Position) >= num)
{
this.rotation = reader.ReadQuaternion();
}
}
示例3: OnDeserialize
//writing to the stream
public override void OnDeserialize(NetworkReader reader, bool initialState)
{
//base.OnDeserialize(reader, initialState);
realPosition = reader.ReadVector3();
realRotation = reader.ReadQuaternion();
/*
Debug.Log("sadddsdadss");
if (stream.isWriting)
{//this is your information you will send over the network
sendPosition = this.transform.position;
sendRotation = this.transform.rotation;
stream.Serialize(ref sendPosition);//im pretty sure you have to use ref here, check that
stream.Serialize(ref sendRotation);//same with the ref here...
}
else if (stream.isReading)
{//this is the information you will recieve over the network
stream.Serialize(ref realPosition);//Vector3 position
stream.Serialize(ref realRotation);//Quaternion postion
}
*/
}
示例4: OnDeserialize
// OnDeserialize is called on the client-side when data is received from the server
public override void OnDeserialize(NetworkReader reader, bool initialState)
{
var rtt = NetworkClient.allClients[0].GetRTT();
var serverFrame = reader.ReadPackedUInt32();
var serverPosition = reader.ReadVector3();
var serverRotation = reader.ReadQuaternion();
var serverForce = reader.ReadVector3();
var checksum = reader.ReadPackedUInt32();
// Create an EntityState from the data given by the server
var serverState = new EntityState
{
position = serverPosition,
rotation = serverRotation,
force = serverForce
};
// Drop the packet if we simulate packet drop
if (NetworkDebugSettings.SimulatedPacketDropPct > 0)
{
var result = Random.Range(0, 100);
if (result <= NetworkDebugSettings.SimulatedPacketDropPct)
{
Debug.LogWarning("Simulated packet drop, server frame: " + serverFrame);
return;
}
}
// Perform checksum and drop bad packets
if (checksum != Checksum(serverState))
{
Debug.LogError("PACKET CRC ERROR");
return;
}
// Discard packets that are out of date.
if (serverFrame < _lastServerFrameForPlayer)
{
Debug.LogError("Discarding old packet");
return; // discard
}
if (NetworkDebugSettings.SimulatedLatency == 0)
{
AcceptUpdateFromServer(rtt, serverFrame, serverState);
}
else
{
StartCoroutine(AcceptUpdateFromServerCoro(rtt, serverFrame, serverState, NetworkDebugSettings.SimulatedLatency/1000f));
}
}
示例5: Deserialize
public override void Deserialize(NetworkReader reader)
{
name = reader.ReadString();
var isNull = reader.ReadBoolean();
if (isNull){
value = null;
return;
}
var typeName = reader.ReadString();
var t = System.Type.GetType(typeName);
if (t == typeof(string)){
value = reader.ReadString();
return;
}
if (t == typeof(bool)){
value = reader.ReadBoolean();
return;
}
if (t == typeof(int)){
value = reader.ReadInt32();
return;
}
if (t == typeof(float)){
value = reader.ReadSingle();
return;
}
if (t == typeof(Color)){
value = reader.ReadColor();
return;
}
if (t == typeof(Vector2)){
value = reader.ReadVector2();
return;
}
if (t == typeof(Vector3)){
value = reader.ReadVector3();
return;
}
if (t == typeof(Vector4)){
value = reader.ReadVector4();
return;
}
if (t == typeof(Quaternion)){
value = reader.ReadQuaternion();
return;
}
if (t == typeof(GameObject)){
value = reader.ReadGameObject();
return;
}
if (typeof(Component).RTIsAssignableFrom(t)){
var go = reader.ReadGameObject();
if (go != null){
value = go.GetComponent(t);
}
return;
}
}