mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Updated TestNT example
This commit is contained in:
parent
6ce4faade5
commit
35b118ba7c
@ -1817,7 +1817,7 @@ public static void OnGUI()
|
||||
// only if in world
|
||||
if (!ready) return;
|
||||
|
||||
GUILayout.BeginArea(new Rect(10, 5, 1020, 50));
|
||||
GUILayout.BeginArea(new Rect(10, 5, 1030, 50));
|
||||
|
||||
GUILayout.BeginHorizontal("Box");
|
||||
GUILayout.Label("Snapshot Interp.:");
|
||||
|
@ -108,7 +108,7 @@ MonoBehaviour:
|
||||
sceneId: 0
|
||||
_assetId: 1176218243
|
||||
serverOnly: 0
|
||||
visible: 0
|
||||
visibility: 0
|
||||
hasSpawned: 0
|
||||
--- !u!114 &710479491816145282
|
||||
MonoBehaviour:
|
||||
@ -119,28 +119,29 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 1428992836745641328}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d65c9604d9da1bc4a8f827172ba44b69, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: 58d4ed8e905e2f0419873bf2d4a973b8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
syncDirection: 1
|
||||
syncMode: 0
|
||||
syncInterval: 0
|
||||
target: {fileID: 3343654733350199237}
|
||||
clientAuthority: 0
|
||||
syncPosition: 1
|
||||
syncRotation: 1
|
||||
syncScale: 0
|
||||
onlySyncOnChange: 1
|
||||
compressRotation: 1
|
||||
interpolatePosition: 1
|
||||
interpolateRotation: 1
|
||||
interpolateScale: 0
|
||||
coordinateSpace: 0
|
||||
sendIntervalMultiplier: 3
|
||||
timelineOffset: 0
|
||||
showGizmos: 0
|
||||
showOverlay: 0
|
||||
overlayColor: {r: 0, g: 0, b: 0, a: 0.5}
|
||||
onlySyncOnChange: 1
|
||||
onlySyncOnChangeCorrectionMultiplier: 2
|
||||
sendIntervalMultiplier: 3
|
||||
rotationSensitivity: 0.02
|
||||
compressRotation: 1
|
||||
positionPrecision: 0.01
|
||||
scalePrecision: 0.01
|
||||
velocity: {x: 0, y: 0, z: 0}
|
||||
@ -192,8 +193,8 @@ MonoBehaviour:
|
||||
syncDirection: 0
|
||||
syncMode: 0
|
||||
syncInterval: 0.1
|
||||
NTRCustomSendInterval: {fileID: 710479491816145282}
|
||||
NetworkTransformReliable: {fileID: 0}
|
||||
NTRCustomSendInterval: {fileID: 0}
|
||||
NetworkTransformReliable: {fileID: 710479491816145282}
|
||||
clientBufferText: {fileID: 2682962751017633123}
|
||||
serverBufferText: {fileID: 8717164079085775202}
|
||||
snapIntText: {fileID: 5541628030175997556}
|
||||
@ -216,7 +217,7 @@ MonoBehaviour:
|
||||
syncDirection: 0
|
||||
syncMode: 0
|
||||
syncInterval: 0.1
|
||||
NTR: {fileID: 710479491816145282}
|
||||
NTR: {fileID: 0}
|
||||
animator: {fileID: 4751401856863927949}
|
||||
characterController: {fileID: 2196882924618641428}
|
||||
physicsMaterial: {fileID: 13400000, guid: c3ac683db06890b49a15dd5009dbd6e8, type: 2}
|
||||
|
@ -241,6 +241,10 @@ PrefabInstance:
|
||||
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[6].m_Arguments.m_ObjectArgumentAssemblyTypeName
|
||||
value: UnityEngine.Object, UnityEngine
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5678319891599719911, guid: 7cf6fcfd5a32c1545bc85a85bfa9c80b, type: 3}
|
||||
propertyPath: m_Value
|
||||
value: 2
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5678319891599719911, guid: 7cf6fcfd5a32c1545bc85a85bfa9c80b, type: 3}
|
||||
propertyPath: m_OnValueChanged.m_PersistentCalls.m_Calls.Array.data[0].m_Target
|
||||
value:
|
||||
@ -377,6 +381,14 @@ PrefabInstance:
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5678319892216973634, guid: 7cf6fcfd5a32c1545bc85a85bfa9c80b, type: 3}
|
||||
propertyPath: m_VertexColorAlwaysGammaSpace
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5678319892216973634, guid: 7cf6fcfd5a32c1545bc85a85bfa9c80b, type: 3}
|
||||
propertyPath: m_AdditionalShaderChannelsFlag
|
||||
value: 25
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5678319892216973638, guid: 7cf6fcfd5a32c1545bc85a85bfa9c80b, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: LoginUI
|
||||
@ -429,21 +441,27 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
dontDestroyOnLoad: 1
|
||||
runInBackground: 1
|
||||
autoStartServerBuild: 1
|
||||
autoConnectClientBuild: 0
|
||||
headlessStartMode: 1
|
||||
editorAutoStart: 0
|
||||
sendRate: 30
|
||||
autoStartServerBuild: 0
|
||||
autoConnectClientBuild: 0
|
||||
offlineScene: Assets/Mirror/Examples/TestNT/Scenes/OfflineKcp.unity
|
||||
onlineScene: Assets/Mirror/Examples/TestNT/Scenes/Online.unity
|
||||
transport: {fileID: 821201142}
|
||||
networkAddress: mirror.clevertech.net
|
||||
networkAddress: localhost
|
||||
maxConnections: 1000
|
||||
disconnectInactiveConnections: 0
|
||||
disconnectInactiveTimeout: 60
|
||||
authenticator: {fileID: 821201138}
|
||||
playerPrefab: {fileID: 2033010110135952297, guid: 10f39bef276942448bfdfba062b6b6e0, type: 3}
|
||||
playerPrefab: {fileID: 1428992836745641328, guid: 4b4e4d1a8090c7a45bab0cbc52ccfd76, type: 3}
|
||||
autoCreatePlayer: 1
|
||||
playerSpawnMethod: 0
|
||||
spawnPrefabs: []
|
||||
exceptionsDisconnect: 1
|
||||
snapshotSettings:
|
||||
bufferTimeMultiplier: 2
|
||||
bufferLimit: 32
|
||||
catchupNegativeThreshold: -1
|
||||
catchupPositiveThreshold: 1
|
||||
catchupSpeed: 0.019999999552965164
|
||||
@ -452,6 +470,8 @@ MonoBehaviour:
|
||||
dynamicAdjustment: 1
|
||||
dynamicAdjustmentTolerance: 1
|
||||
deliveryTimeEmaDuration: 2
|
||||
evaluationMethod: 0
|
||||
evaluationInterval: 3
|
||||
timeInterpolationGui: 1
|
||||
playerNinjaPrefab: {fileID: 9193589764031967748, guid: 7903ea74806680c4f9f3a62da96765c2, type: 3}
|
||||
botPrefab: {fileID: 629047657802428152, guid: 45e99b6415bfdc846bbbfc2d949d53f5, type: 3}
|
||||
@ -579,7 +599,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 6b0fecffa3f624585964b0d0eb21b18e, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
Port: 7777
|
||||
port: 7777
|
||||
DualMode: 1
|
||||
NoDelay: 1
|
||||
Interval: 10
|
||||
@ -591,8 +611,8 @@ MonoBehaviour:
|
||||
SendWindowSize: 4096
|
||||
MaxRetransmit: 40
|
||||
MaximizeSocketBuffers: 1
|
||||
ReliableMaxMessageSize: 298449
|
||||
UnreliableMaxMessageSize: 1199
|
||||
ReliableMaxMessageSize: 297433
|
||||
UnreliableMaxMessageSize: 1194
|
||||
debugLog: 0
|
||||
statisticsGUI: 0
|
||||
statisticsLog: 0
|
||||
|
@ -6,9 +6,9 @@
|
||||
|
||||
public class NTRCustomSendInterval : NetworkTransformBase
|
||||
{
|
||||
[Header("Sync Only If Changed")]
|
||||
[Tooltip("When true, changes are not sent unless greater than sensitivity values below.")]
|
||||
public bool onlySyncOnChange = true;
|
||||
//[Header("Sync Only If Changed")]
|
||||
//[Tooltip("When true, changes are not sent unless greater than sensitivity values below.")]
|
||||
//public bool onlySyncOnChange = true;
|
||||
float onlySyncOnChangeInterval => onlySyncOnChangeCorrectionMultiplier * sendIntervalMultiplier;
|
||||
|
||||
[Tooltip("If we only sync on change, then we need to correct old snapshots if more time than sendInterval * multiplier has elapsed.\n\nOtherwise the first move will always start interpolating from the last move sequence's time, which will make it stutter when starting every time.")]
|
||||
@ -22,8 +22,8 @@ public class NTRCustomSendInterval : NetworkTransformBase
|
||||
[Header("Rotation")]
|
||||
[Tooltip("Sensitivity of changes needed before an updated state is sent over the network")]
|
||||
public float rotationSensitivity = 0.01f;
|
||||
[Tooltip("Apply smallest-three quaternion compression. This is lossy, you can disable it if the small rotation inaccuracies are noticeable in your project.")]
|
||||
public bool compressRotation = false;
|
||||
//[Tooltip("Apply smallest-three quaternion compression. This is lossy, you can disable it if the small rotation inaccuracies are noticeable in your project.")]
|
||||
//public bool compressRotation = false;
|
||||
|
||||
// delta compression is capable of detecting byte-level changes.
|
||||
// if we scale float position to bytes,
|
||||
|
@ -14,14 +14,14 @@ public class NTReliableExt : NetworkTransformReliable
|
||||
|
||||
protected override void Apply(TransformSnapshot interpolated, TransformSnapshot endGoal)
|
||||
{
|
||||
base.Apply(interpolated, endGoal);
|
||||
|
||||
if (!isOwned)
|
||||
{
|
||||
velocity = (transform.position - interpolated.position) / Time.deltaTime;
|
||||
angVelocity = (transform.rotation.eulerAngles - interpolated.rotation.eulerAngles) / Time.deltaTime;
|
||||
VelRotChangedAction?.Invoke(velocity, angVelocity);
|
||||
}
|
||||
|
||||
base.Apply(interpolated, endGoal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,8 @@ public enum GroundState : byte { Jumping, Falling, Grounded }
|
||||
public enum MoveMode : byte { Walking, Sneaking, Running };
|
||||
|
||||
[Header("Avatar Components")]
|
||||
public NTRCustomSendInterval NTR;
|
||||
//public NTRCustomSendInterval NTR;
|
||||
public NTReliableExt NTR;
|
||||
public Animator animator;
|
||||
public CharacterController characterController;
|
||||
|
||||
@ -65,7 +66,8 @@ protected override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
if (NTR == null)
|
||||
NTR = GetComponentInChildren<NTRCustomSendInterval>();
|
||||
NTR = GetComponentInChildren<NTReliableExt>();
|
||||
//NTR = GetComponentInChildren<NTRCustomSendInterval>();
|
||||
|
||||
if (animator == null)
|
||||
animator = GetComponentInChildren<Animator>();
|
||||
@ -324,7 +326,7 @@ void HandleAnimation()
|
||||
void OnVelRotChanged(Vector3 newVelocity, Vector3 newRotation)
|
||||
{
|
||||
// Only apply to other player objects
|
||||
if (isLocalPlayer) return;
|
||||
//if (isLocalPlayer) return;
|
||||
|
||||
animVelocity = -MathF.Round(transform.InverseTransformDirection(newVelocity).z / moveSpeedMultiplier, 1);
|
||||
animRotation = -MathF.Round(newRotation.y / maxTurnSpeed, 1);
|
||||
|
Loading…
Reference in New Issue
Block a user