本文整理汇总了C#中NetworkReader.ReadVector3方法的典型用法代码示例。如果您正苦于以下问题:C# NetworkReader.ReadVector3方法的具体用法?C# NetworkReader.ReadVector3怎么用?C# NetworkReader.ReadVector3使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetworkReader
的用法示例。
在下文中一共展示了NetworkReader.ReadVector3方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Deserialize
public override void Deserialize(NetworkReader reader)
{
this.netId = reader.ReadNetworkId();
this.sceneId = reader.ReadSceneId();
this.position = reader.ReadVector3();
this.payload = reader.ReadBytesAndSize();
}
示例2: OnDeserialize
public override void OnDeserialize(NetworkReader reader, bool initialState)
{
/*
Interpolate: pass reader as parameter to fbxobj
*/
fbxObj.gameObject.transform.position = reader.ReadVector3();
}
示例3: 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);
}
}
}
示例4: Deserialize
public override void Deserialize(NetworkReader reader)
{
base.Deserialize(reader);
int count = reader.ReadInt32();
Polyline = new List<Vector3>(count);
for(int i=0; i < count; i++)
Polyline.Add(reader.ReadVector3());
}
示例5: 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();
}
}
示例6: 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
}
*/
}
示例7: Deserialize
public override void Deserialize(NetworkReader reader)
{
m_id = reader.ReadNetworkId();
m_parentId = reader.ReadNetworkId();
m_childId = reader.ReadInt32();
m_position = reader.ReadVector3();
m_payload = reader.ReadBytesAndSize();
}
示例8: UnserializeModeCharacterController
private void UnserializeModeCharacterController(NetworkReader reader, bool initialState)
{
if ((UnityEngine.Object) this.m_CharacterController == (UnityEngine.Object) null)
return;
this.m_TargetSyncPosition = reader.ReadVector3();
this.m_FixedPosDiff = (this.m_TargetSyncPosition - this.transform.position) / this.GetNetworkSendInterval() * Time.fixedDeltaTime;
if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
this.m_TargetSyncRotation3D = this.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
if (this.isServer && !this.isClient)
{
this.transform.position = this.m_TargetSyncPosition;
this.transform.rotation = this.m_TargetSyncRotation3D;
}
else if ((double) this.GetNetworkSendInterval() == 0.0)
{
this.transform.position = this.m_TargetSyncPosition;
if (this.syncRotationAxis == NetworkTransform.AxisSyncMode.None)
return;
this.transform.rotation = this.m_TargetSyncRotation3D;
}
else
{
if ((double) (this.transform.position - this.m_TargetSyncPosition).magnitude > (double) this.snapThreshold)
this.transform.position = this.m_TargetSyncPosition;
if ((double) this.interpolateRotation == 0.0)
this.transform.rotation = this.m_TargetSyncRotation3D;
if ((double) this.m_InterpolateMovement == 0.0)
this.transform.position = this.m_TargetSyncPosition;
if (!initialState)
return;
this.transform.rotation = this.m_TargetSyncRotation3D;
}
}
示例9: UnserializeModeTransform
private void UnserializeModeTransform(NetworkReader reader, bool initialState)
{
if (this.hasAuthority)
{
reader.ReadVector3();
if (this.syncRotationAxis == NetworkTransform.AxisSyncMode.None)
return;
NetworkTransform.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
}
else if (this.isServer && this.m_ClientMoveCallback3D != null)
{
Vector3 position = reader.ReadVector3();
Vector3 zero = Vector3.zero;
Quaternion rotation = Quaternion.identity;
if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
rotation = NetworkTransform.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
if (!this.m_ClientMoveCallback3D(ref position, ref zero, ref rotation))
return;
this.m_TargetSyncPosition = position;
if (this.syncRotationAxis == NetworkTransform.AxisSyncMode.None)
return;
this.m_TargetSyncRotation3D = rotation;
}
else
{
this.m_TargetSyncPosition = reader.ReadVector3();
if (this.syncRotationAxis == NetworkTransform.AxisSyncMode.None)
return;
this.m_TargetSyncRotation3D = NetworkTransform.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
}
}
示例10: UnserializeMode3D
private void UnserializeMode3D(NetworkReader reader, bool initialState)
{
if (this.hasAuthority)
{
reader.ReadVector3();
reader.ReadVector3();
if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
NetworkTransform.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
if (!this.syncSpin)
return;
NetworkTransform.UnserializeSpin3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
}
else
{
if (this.isServer && this.m_ClientMoveCallback3D != null)
{
Vector3 position = reader.ReadVector3();
Vector3 velocity = reader.ReadVector3();
Quaternion rotation = Quaternion.identity;
if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
rotation = NetworkTransform.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
if (!this.m_ClientMoveCallback3D(ref position, ref velocity, ref rotation))
return;
this.m_TargetSyncPosition = position;
this.m_TargetSyncVelocity = velocity;
if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
this.m_TargetSyncRotation3D = rotation;
}
else
{
this.m_TargetSyncPosition = reader.ReadVector3();
this.m_TargetSyncVelocity = reader.ReadVector3();
if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
this.m_TargetSyncRotation3D = NetworkTransform.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
}
if (this.syncSpin)
this.m_TargetSyncAngularVelocity3D = NetworkTransform.UnserializeSpin3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
if ((UnityEngine.Object) this.m_RigidBody3D == (UnityEngine.Object) null)
return;
if (this.isServer && !this.isClient)
{
this.m_RigidBody3D.MovePosition(this.m_TargetSyncPosition);
this.m_RigidBody3D.MoveRotation(this.m_TargetSyncRotation3D);
this.m_RigidBody3D.velocity = this.m_TargetSyncVelocity;
}
else if ((double) this.GetNetworkSendInterval() == 0.0)
{
this.m_RigidBody3D.MovePosition(this.m_TargetSyncPosition);
this.m_RigidBody3D.velocity = this.m_TargetSyncVelocity;
if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
this.m_RigidBody3D.MoveRotation(this.m_TargetSyncRotation3D);
if (!this.syncSpin)
return;
this.m_RigidBody3D.angularVelocity = this.m_TargetSyncAngularVelocity3D;
}
else
{
if ((double) (this.m_RigidBody3D.position - this.m_TargetSyncPosition).magnitude > (double) this.snapThreshold)
{
this.m_RigidBody3D.position = this.m_TargetSyncPosition;
this.m_RigidBody3D.velocity = this.m_TargetSyncVelocity;
}
if ((double) this.interpolateRotation == 0.0 && this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
{
this.m_RigidBody3D.rotation = this.m_TargetSyncRotation3D;
if (this.syncSpin)
this.m_RigidBody3D.angularVelocity = this.m_TargetSyncAngularVelocity3D;
}
if ((double) this.m_InterpolateMovement == 0.0)
this.m_RigidBody3D.position = this.m_TargetSyncPosition;
if (!initialState || this.syncRotationAxis == NetworkTransform.AxisSyncMode.None)
return;
this.m_RigidBody3D.rotation = this.m_TargetSyncRotation3D;
}
}
}
示例11: UnserializeModeCharacterController
private void UnserializeModeCharacterController(NetworkReader reader, bool initialState)
{
if (this.hasAuthority)
{
reader.ReadVector3();
if (this.syncRotationAxis == NetworkTransform.AxisSyncMode.None)
return;
NetworkTransform.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
}
else
{
if (this.isServer && this.m_ClientMoveCallback3D != null)
{
Vector3 position = reader.ReadVector3();
Quaternion rotation = Quaternion.identity;
if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
rotation = NetworkTransform.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
if ((UnityEngine.Object) this.m_CharacterController == (UnityEngine.Object) null)
return;
Vector3 velocity = this.m_CharacterController.velocity;
if (!this.m_ClientMoveCallback3D(ref position, ref velocity, ref rotation))
return;
this.m_TargetSyncPosition = position;
this.m_TargetSyncVelocity = velocity;
if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
this.m_TargetSyncRotation3D = rotation;
}
else
{
this.m_TargetSyncPosition = reader.ReadVector3();
if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
this.m_TargetSyncRotation3D = NetworkTransform.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
}
if ((UnityEngine.Object) this.m_CharacterController == (UnityEngine.Object) null)
return;
this.m_FixedPosDiff = (this.m_TargetSyncPosition - this.transform.position) / this.GetNetworkSendInterval() * Time.fixedDeltaTime;
if (this.isServer && !this.isClient)
{
this.transform.position = this.m_TargetSyncPosition;
this.transform.rotation = this.m_TargetSyncRotation3D;
}
else if ((double) this.GetNetworkSendInterval() == 0.0)
{
this.transform.position = this.m_TargetSyncPosition;
if (this.syncRotationAxis == NetworkTransform.AxisSyncMode.None)
return;
this.transform.rotation = this.m_TargetSyncRotation3D;
}
else
{
if ((double) (this.transform.position - this.m_TargetSyncPosition).magnitude > (double) this.snapThreshold)
this.transform.position = this.m_TargetSyncPosition;
if ((double) this.interpolateRotation == 0.0 && this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
this.transform.rotation = this.m_TargetSyncRotation3D;
if ((double) this.m_InterpolateMovement == 0.0)
this.transform.position = this.m_TargetSyncPosition;
if (!initialState || this.syncRotationAxis == NetworkTransform.AxisSyncMode.None)
return;
this.transform.rotation = this.m_TargetSyncRotation3D;
}
}
}
示例12: 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;
}
}
示例13: UnserializeVelocity3D
public static Vector3 UnserializeVelocity3D(NetworkReader reader, NetworkTransform.CompressionSyncMode compression)
{
return reader.ReadVector3();
}
示例14: UnserializeModeTransform
private void UnserializeModeTransform(NetworkReader reader, bool initialState)
{
this.transform.position = reader.ReadVector3();
if (this.syncRotationAxis == NetworkTransform.AxisSyncMode.None)
return;
this.transform.rotation = this.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression);
}
示例15: 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));
}
}