PlayerTest: Spawns NTR and NTU alongside Hybrid

This commit is contained in:
MrGadget 2024-09-24 05:08:08 -04:00
parent be16cc7c99
commit f60d48bc19
9 changed files with 155 additions and 41 deletions

View File

@ -121,6 +121,7 @@ public uint sendIntervalMultiplier
// debugging ///////////////////////////////////////////////////////////
[Header("Debug")]
public bool debugDraw = false;
public bool showGizmos;
public bool showOverlay;
public Color overlayColor = new Color(0, 0, 0, 0.5f);

View File

@ -254,7 +254,11 @@ public override void OnDeserialize(NetworkReader reader, bool initialState)
// initial
if (initialState)
{
if (syncPosition) position = reader.ReadVector3();
if (syncPosition)
{
position = reader.ReadVector3();
if (debugDraw) Debug.DrawLine(position.Value, position.Value + Vector3.up, Color.green, 10.0f);
}
if (syncRotation)
{
// (optional) smallest three compression for now. no delta.
@ -273,6 +277,7 @@ public override void OnDeserialize(NetworkReader reader, bool initialState)
{
Vector3Long quantized = DeltaCompression.Decompress(reader, lastDeserializedPosition);
position = Compression.ScaleToFloat(quantized, positionPrecision);
if (debugDraw) Debug.DrawLine(position.Value, position.Value + Vector3.up, Color.yellow, 10.0f);
}
if (syncRotation)
{

View File

@ -267,7 +267,12 @@ public override void OnDeserialize(NetworkReader reader, bool initialState)
// (Spawn message wouldn't sync NTChild positions either)
if (initialState)
{
if (syncPosition) SetPosition(reader.ReadVector3());
if (syncPosition)
{
Vector3 position = reader.ReadVector3();
if (debugDraw) Debug.DrawLine(position, position + Vector3.up, Color.green, 10.0f);
SetPosition(position);
}
if (syncRotation) SetRotation(reader.ReadQuaternion());
if (syncScale) SetScale(reader.ReadVector3());
}

View File

@ -28,8 +28,8 @@ public class NetworkTransformUnreliableCompressed : NetworkTransformBase
[Range(0.00_01f, 1f)] // disallow 0 division. 1mm to 1m precision is enough range.
public float scalePrecision = 0.01f; // 1 cm
[Header("Debug")]
public bool debugDraw = false;
//[Header("Debug")]
//public bool debugDraw = false;
protected Vector4Long lastSerializedRotation = Vector4Long.zero;
protected Vector4Long lastDeserializedRotation = Vector4Long.zero;

View File

@ -339,8 +339,8 @@ MonoBehaviour:
syncDirection: 0
syncMode: 0
syncInterval: 0
offset: {x: 0, y: 3, z: -12}
rotation: {x: 10, y: 0, z: 0}
offset: {x: 0, y: 8, z: -8}
rotation: {x: 40, y: 0, z: 0}
--- !u!114 &-3152658994415891009
MonoBehaviour:
m_ObjectHideFlags: 0
@ -368,6 +368,7 @@ MonoBehaviour:
interpolateScale: 1
coordinateSpace: 0
timelineOffset: 1
debugDraw: 1
showGizmos: 1
showOverlay: 1
overlayColor: {r: 0, g: 0, b: 0, a: 0.5}
@ -375,7 +376,6 @@ MonoBehaviour:
positionPrecision: 0.01
rotationPrecision: 0.001
scalePrecision: 0.01
debugDraw: 1
--- !u!114 &-869730508439457933
MonoBehaviour:
m_ObjectHideFlags: 0
@ -407,7 +407,7 @@ MonoBehaviour:
AutoRun: 114
ToggleUI: 117
controlOptions: 2
maxMoveSpeed: 10
maxMoveSpeed: 8
inputSensitivity: 2
inputGravity: 2
maxTurnSpeed: 100

View File

@ -25,12 +25,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4592122871669721618}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0.39999998, z: 0.5}
m_LocalScale: {x: 0.5, y: 0.1, z: 0.2}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 3834521907656645861}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &7450643213444322531
MeshFilter:
@ -51,10 +52,14 @@ MeshRenderer:
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_RenderingLayerMask: 4294967295
m_RendererPriority: 0
m_Materials:
@ -79,6 +84,7 @@ MeshRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!1 &5844787331012650587
GameObject:
m_ObjectHideFlags: 0
@ -104,13 +110,14 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5844787331012650587}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 5246057292441020322}
m_Father: {fileID: 4659514702152478195}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &7647174189108629449
MeshFilter:
@ -131,10 +138,14 @@ MeshRenderer:
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
@ -159,6 +170,7 @@ MeshRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!1 &7863680369626900553
GameObject:
m_ObjectHideFlags: 0
@ -190,13 +202,14 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863680369626900553}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1.1, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 3834521907656645861}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!136 &4284051235536850638
CapsuleCollider:
@ -206,8 +219,17 @@ CapsuleCollider:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863680369626900553}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.5
m_Height: 2
m_Direction: 1
@ -220,9 +242,17 @@ CharacterController:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863680369626900553}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 0
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 0
serializedVersion: 3
m_Height: 2
m_Radius: 0.5
m_SlopeLimit: 45
@ -237,10 +267,21 @@ Rigidbody:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863680369626900553}
serializedVersion: 2
serializedVersion: 4
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_CenterOfMass: {x: 0, y: 0, z: 0}
m_InertiaTensor: {x: 1, y: 1, z: 1}
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_ImplicitCom: 1
m_ImplicitTensor: 1
m_UseGravity: 1
m_IsKinematic: 1
m_Interpolate: 0
@ -259,7 +300,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
sceneId: 0
_assetId: 2059247497
_assetId: 810734400
serverOnly: 0
visibility: 0
hasSpawned: 0
@ -275,6 +316,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: a91a718a70d01b347b75cb768a6f1a92, type: 3}
m_Name:
m_EditorClassIdentifier:
syncMethod: 0
syncDirection: 0
syncMode: 0
syncInterval: 0
@ -293,11 +335,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 71ac1e35462ffad469e77d1c2fe6c9f3, type: 3}
m_Name:
m_EditorClassIdentifier:
syncMethod: 0
syncDirection: 0
syncMode: 0
syncInterval: 0
offset: {x: 0, y: 3, z: -8}
rotation: {x: 10, y: 0, z: 0}
offset: {x: 0, y: 8, z: -8}
rotation: {x: 40, y: 0, z: 0}
--- !u!114 &5382001159774817068
MonoBehaviour:
m_ObjectHideFlags: 0
@ -310,6 +353,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 8ff3ba0becae47b8b9381191598957c8, type: 3}
m_Name:
m_EditorClassIdentifier:
syncMethod: 0
syncDirection: 1
syncMode: 0
syncInterval: 0
@ -323,9 +367,10 @@ MonoBehaviour:
interpolateRotation: 1
interpolateScale: 1
coordinateSpace: 0
timelineOffset: 0
showGizmos: 0
showOverlay: 0
timelineOffset: 1
debugDraw: 1
showGizmos: 1
showOverlay: 1
overlayColor: {r: 0, g: 0, b: 0, a: 0.5}
onlySyncOnChangeCorrectionMultiplier: 2
rotationSensitivity: 0.01
@ -343,12 +388,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 497221e839119e34b897d6c497cbc8e5, type: 3}
m_Name:
m_EditorClassIdentifier:
syncMethod: 0
syncDirection: 0
syncMode: 0
syncInterval: 0
characterController: {fileID: 1014105431373575527}
ControllerUIPrefab: {fileID: 644766297742565710, guid: 7beee247444994f0281dadde274cc4af,
type: 3}
ControllerUIPrefab: {fileID: 644766297742565710, guid: 7beee247444994f0281dadde274cc4af, type: 3}
moveKeys:
Forward: 119
Back: 115
@ -361,7 +406,7 @@ MonoBehaviour:
MouseSteer: 109
AutoRun: 114
ToggleUI: 117
controlOptions: 4
controlOptions: 2
maxMoveSpeed: 8
inputSensitivity: 2
inputGravity: 2

View File

@ -153,6 +153,16 @@ public override void OnServerReady(NetworkConnectionToClient conn)
public override void OnServerAddPlayer(NetworkConnectionToClient conn)
{
base.OnServerAddPlayer(conn);
StartCoroutine(SpawnExtras(conn));
}
IEnumerator SpawnExtras(NetworkConnectionToClient conn)
{
yield return new WaitForSeconds(0.1f);
Vector3 startPos = conn.identity.transform.position;
NetworkServer.Spawn(Instantiate(spawnPrefabs[0], startPos + new Vector3(0, 0, -2f), Quaternion.identity), conn);
yield return new WaitForSeconds(0.1f);
NetworkServer.Spawn(Instantiate(spawnPrefabs[1], startPos + new Vector3(0, 0, 2f), Quaternion.identity), conn);
}
/// <summary>

View File

@ -278,6 +278,7 @@ MonoBehaviour:
interpolateScale: 1
coordinateSpace: 0
timelineOffset: 0
debugDraw: 0
showGizmos: 0
showOverlay: 0
overlayColor: {r: 0, g: 0, b: 0, a: 0.5}
@ -455,7 +456,7 @@ Transform:
m_GameObject: {fileID: 890531170}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -20000, y: 1.02, z: 3}
m_LocalPosition: {x: -20000, y: 1.02, z: 12}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
@ -499,7 +500,7 @@ Transform:
m_GameObject: {fileID: 980545347}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -20010, y: 1.02, z: 1}
m_LocalPosition: {x: -20010, y: 1.02, z: 4}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
@ -543,7 +544,7 @@ Transform:
m_GameObject: {fileID: 1175360880}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -20020, y: 1.02, z: -1}
m_LocalPosition: {x: -20020, y: 1.02, z: -4}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
@ -680,7 +681,7 @@ Transform:
m_GameObject: {fileID: 1708370876}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -20030, y: 1.02, z: -3}
m_LocalPosition: {x: -20030, y: 1.02, z: -12}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
@ -874,7 +875,9 @@ MonoBehaviour:
playerPrefab: {fileID: 7863680369626900553, guid: ced318e1e70bb294baac46b2bfe34e0e, type: 3}
autoCreatePlayer: 1
playerSpawnMethod: 1
spawnPrefabs: []
spawnPrefabs:
- {fileID: 7863680369626900553, guid: 34c79b503a7a04847be9745d119b655d, type: 3}
- {fileID: 7863680369626900553, guid: 400bac1c9e1e96648a83f333d4837484, type: 3}
exceptionsDisconnect: 1
snapshotSettings:
bufferTimeMultiplier: 2

View File

@ -25,12 +25,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4592122871669721618}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0.39999998, z: 0.5}
m_LocalScale: {x: 0.5, y: 0.1, z: 0.2}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 3834521907656645861}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &7450643213444322531
MeshFilter:
@ -51,10 +52,14 @@ MeshRenderer:
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_RenderingLayerMask: 4294967295
m_RendererPriority: 0
m_Materials:
@ -79,6 +84,7 @@ MeshRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!1 &5844787331012650587
GameObject:
m_ObjectHideFlags: 0
@ -104,13 +110,14 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5844787331012650587}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 5246057292441020322}
m_Father: {fileID: 4659514702152478195}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &7647174189108629449
MeshFilter:
@ -131,10 +138,14 @@ MeshRenderer:
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
@ -159,6 +170,7 @@ MeshRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!1 &7863680369626900553
GameObject:
m_ObjectHideFlags: 0
@ -190,13 +202,14 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863680369626900553}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1.1, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 3834521907656645861}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!136 &4284051235536850638
CapsuleCollider:
@ -206,8 +219,17 @@ CapsuleCollider:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863680369626900553}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.5
m_Height: 2
m_Direction: 1
@ -220,9 +242,17 @@ CharacterController:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863680369626900553}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 0
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 0
serializedVersion: 3
m_Height: 2
m_Radius: 0.5
m_SlopeLimit: 45
@ -237,10 +267,21 @@ Rigidbody:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863680369626900553}
serializedVersion: 2
serializedVersion: 4
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_CenterOfMass: {x: 0, y: 0, z: 0}
m_InertiaTensor: {x: 1, y: 1, z: 1}
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_ImplicitCom: 1
m_ImplicitTensor: 1
m_UseGravity: 1
m_IsKinematic: 1
m_Interpolate: 0
@ -259,7 +300,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
sceneId: 0
_assetId: 756366076
_assetId: 1642607196
serverOnly: 0
visibility: 0
hasSpawned: 0
@ -275,6 +316,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: a91a718a70d01b347b75cb768a6f1a92, type: 3}
m_Name:
m_EditorClassIdentifier:
syncMethod: 0
syncDirection: 0
syncMode: 0
syncInterval: 0
@ -293,11 +335,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 71ac1e35462ffad469e77d1c2fe6c9f3, type: 3}
m_Name:
m_EditorClassIdentifier:
syncMethod: 0
syncDirection: 0
syncMode: 0
syncInterval: 0
offset: {x: 0, y: 3, z: -8}
rotation: {x: 10, y: 0, z: 0}
offset: {x: 0, y: 8, z: -8}
rotation: {x: 40, y: 0, z: 0}
--- !u!114 &1260535960049292642
MonoBehaviour:
m_ObjectHideFlags: 0
@ -310,6 +353,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: a553cb17010b2403e8523b558bffbc14, type: 3}
m_Name:
m_EditorClassIdentifier:
syncMethod: 1
syncDirection: 1
syncMode: 0
syncInterval: 0
@ -323,9 +367,10 @@ MonoBehaviour:
interpolateRotation: 1
interpolateScale: 1
coordinateSpace: 0
timelineOffset: 0
showGizmos: 0
showOverlay: 0
timelineOffset: 1
debugDraw: 1
showGizmos: 1
showOverlay: 1
overlayColor: {r: 0, g: 0, b: 0, a: 0.5}
bufferResetMultiplier: 3
positionSensitivity: 0.01
@ -343,12 +388,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f81b59082839c2e40938767457bb91ae, type: 3}
m_Name:
m_EditorClassIdentifier:
syncMethod: 0
syncDirection: 0
syncMode: 0
syncInterval: 0
characterController: {fileID: 1014105431373575527}
ControllerUIPrefab: {fileID: 644766297742565710, guid: 7beee247444994f0281dadde274cc4af,
type: 3}
ControllerUIPrefab: {fileID: 644766297742565710, guid: 7beee247444994f0281dadde274cc4af, type: 3}
moveKeys:
Forward: 119
Back: 115
@ -361,7 +406,7 @@ MonoBehaviour:
MouseSteer: 109
AutoRun: 114
ToggleUI: 117
controlOptions: 4
controlOptions: 2
maxMoveSpeed: 8
inputSensitivity: 2
inputGravity: 2