diff --git a/DarkFlow/Assets/Characters/1_Mutant/Mutant.prefab b/DarkFlow/Assets/Characters/1_Mutant/Mutant.prefab index 6b42e95..21b545e 100644 --- a/DarkFlow/Assets/Characters/1_Mutant/Mutant.prefab +++ b/DarkFlow/Assets/Characters/1_Mutant/Mutant.prefab @@ -813,10 +813,6 @@ PrefabInstance: type: 3} insertIndex: -1 addedObject: {fileID: 8027232384722410602} - - targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: a65433442e687234ab8043c546677d72, - type: 3} - insertIndex: -1 - addedObject: {fileID: 8825393132258296762} - targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: a65433442e687234ab8043c546677d72, type: 3} insertIndex: -1 @@ -913,7 +909,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 62899f850307741f2a39c98a8b639597, type: 3} m_Name: m_EditorClassIdentifier: - m_Actions: {fileID: -944628639613478452, guid: 4419d82f33d36e848b3ed5af4c8da37e, + m_Actions: {fileID: -944628639613478452, guid: 42bbd845906c9dd4fa77e979ee644342, type: 3} m_NotificationBehavior: 0 m_UIInputModule: {fileID: 0} @@ -1045,21 +1041,6 @@ MonoBehaviour: m_EditorClassIdentifier: TransitionStateInfoList: [] m_Animator: {fileID: 222671947941112760} ---- !u!114 &8825393132258296762 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2247144937675617167} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: f05cd39e2b8b7604caee407644cd00c3, type: 3} - m_Name: - m_EditorClassIdentifier: - isObjectPickedUp: - m_InternalValue: 0 - m_LocalHeldPosition: {x: 0, y: 2.85, z: 0} --- !u!114 &5652289010296803950 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1072,7 +1053,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 854c882e4139d184fbbe7fef3fa272e2, type: 3} m_Name: m_EditorClassIdentifier: - m_ServerPlayerMove: {fileID: 8825393132258296762} m_CharacterController: {fileID: 2129690468861909873} m_ThirdPersonController: {fileID: 5509808468128901478} m_CameraFollow: {fileID: 994559427591439665} diff --git a/DarkFlow/Assets/Characters/2_Erika/Erika.prefab b/DarkFlow/Assets/Characters/2_Erika/Erika.prefab index 1eb47ae..ba04ec2 100644 --- a/DarkFlow/Assets/Characters/2_Erika/Erika.prefab +++ b/DarkFlow/Assets/Characters/2_Erika/Erika.prefab @@ -1283,10 +1283,6 @@ PrefabInstance: type: 3} insertIndex: -1 addedObject: {fileID: 7905829003486985161} - - targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: 4f52f003eca24b843924f016ea500470, - type: 3} - insertIndex: -1 - addedObject: {fileID: 716503057832604298} - targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: 4f52f003eca24b843924f016ea500470, type: 3} insertIndex: -1 @@ -1377,7 +1373,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 62899f850307741f2a39c98a8b639597, type: 3} m_Name: m_EditorClassIdentifier: - m_Actions: {fileID: -944628639613478452, guid: 4419d82f33d36e848b3ed5af4c8da37e, + m_Actions: {fileID: -944628639613478452, guid: 42bbd845906c9dd4fa77e979ee644342, type: 3} m_NotificationBehavior: 0 m_UIInputModule: {fileID: 0} @@ -1493,21 +1489,6 @@ MonoBehaviour: m_EditorClassIdentifier: TransitionStateInfoList: [] m_Animator: {fileID: 7385380308929055139} ---- !u!114 &716503057832604298 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4663426026667250098} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: f05cd39e2b8b7604caee407644cd00c3, type: 3} - m_Name: - m_EditorClassIdentifier: - isObjectPickedUp: - m_InternalValue: 0 - m_LocalHeldPosition: {x: 0, y: 2.85, z: 0} --- !u!114 &800218253002373474 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1520,7 +1501,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 854c882e4139d184fbbe7fef3fa272e2, type: 3} m_Name: m_EditorClassIdentifier: - m_ServerPlayerMove: {fileID: 716503057832604298} m_CharacterController: {fileID: 4810382554605961037} m_ThirdPersonController: {fileID: 3088514794462180247} m_CameraFollow: {fileID: 8408292032187987872} diff --git a/DarkFlow/Assets/Prefabs/EmptPlayer.prefab b/DarkFlow/Assets/Prefabs/EmptPlayer.prefab index 1deac79..54ac5e8 100644 --- a/DarkFlow/Assets/Prefabs/EmptPlayer.prefab +++ b/DarkFlow/Assets/Prefabs/EmptPlayer.prefab @@ -1,67 +1,5 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: ---- !u!1 &3984814823395178536 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 5203344646249168406} - - component: {fileID: 8304618723454314381} - - component: {fileID: 5759118789581747785} - m_Layer: 0 - m_Name: cm - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &5203344646249168406 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 3984814823395178536} - 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: 1 - m_Children: [] - m_Father: {fileID: 8854747452121219814} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &8304618723454314381 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 3984814823395178536} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: ac0b09e7857660247b1477e93731de29, type: 3} - m_Name: - m_EditorClassIdentifier: ---- !u!114 &5759118789581747785 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 3984814823395178536} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 68bb026fafb42b14791938953eaace77, type: 3} - m_Name: - m_EditorClassIdentifier: - m_NoiseProfile: {fileID: 0} - m_PivotOffset: {x: 0, y: 0, z: 1} - m_AmplitudeGain: 0.5 - m_FrequencyGain: 0.3 - mNoiseOffsets: {x: 0, y: 0, z: 0} --- !u!1 &8854747452121219810 GameObject: m_ObjectHideFlags: 0 @@ -91,8 +29,7 @@ Transform: m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 5203344646249168406} + m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &8854747452121219813 @@ -107,7 +44,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3} m_Name: m_EditorClassIdentifier: - GlobalObjectIdHash: 3761423118 + GlobalObjectIdHash: 3783676955 AlwaysReplicateAsRoot: 0 SynchronizeTransform: 1 ActiveSceneSynchronization: 0 diff --git a/DarkFlow/Assets/Prefabs/EnvironmentMain.prefab b/DarkFlow/Assets/Prefabs/EnvironmentMain.prefab index 3ed3bea..464f240 100644 --- a/DarkFlow/Assets/Prefabs/EnvironmentMain.prefab +++ b/DarkFlow/Assets/Prefabs/EnvironmentMain.prefab @@ -28,7 +28,7 @@ Transform: m_GameObject: {fileID: 3380972484498700283} serializedVersion: 2 m_LocalRotation: {x: -0.000000021855694, y: 0, z: -0, w: 1} - m_LocalPosition: {x: -1.644872, y: 0.36, z: -1.72} + m_LocalPosition: {x: 1.07, y: 0.49, z: -5.02} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 1 m_Children: [] @@ -105,6 +105,111 @@ BoxCollider: serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} +--- !u!1 &8689410107795753702 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 6323771381898580408} + - component: {fileID: 7341639026134730347} + - component: {fileID: 3351374400316864635} + - component: {fileID: 3478337274159224239} + m_Layer: 0 + m_Name: Cube (1) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &6323771381898580408 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8689410107795753702} + serializedVersion: 2 + m_LocalRotation: {x: -0.000000021855694, y: 0, z: -0, w: 1} + m_LocalPosition: {x: 1.35, y: 0.98, z: -4.37} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 1 + m_Children: [] + m_Father: {fileID: 4474145340166388366} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &7341639026134730347 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8689410107795753702} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &3351374400316864635 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8689410107795753702} + m_Enabled: 1 + 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_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!65 &3478337274159224239 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8689410107795753702} + 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: 3 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} --- !u!1001 &4151722947518356837 PrefabInstance: m_ObjectHideFlags: 0 @@ -185,6 +290,10 @@ PrefabInstance: type: 3} insertIndex: -1 addedObject: {fileID: 8609971574843151533} + - targetCorrespondingSourceObject: {fileID: -8679921383154817045, guid: 4eecdfa58a695ad42ab75e464e6130bf, + type: 3} + insertIndex: -1 + addedObject: {fileID: 6323771381898580408} m_AddedComponents: - targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: 4eecdfa58a695ad42ab75e464e6130bf, type: 3} diff --git a/DarkFlow/Assets/Prefabs/GameObject.prefab b/DarkFlow/Assets/Prefabs/GameObject.prefab deleted file mode 100644 index 4b1d8ce..0000000 --- a/DarkFlow/Assets/Prefabs/GameObject.prefab +++ /dev/null @@ -1,33 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!1 &512425510666679738 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 6665026896159044337} - m_Layer: 0 - m_Name: GameObject - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &6665026896159044337 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 512425510666679738} - 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: 1 - m_Children: [] - m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/DarkFlow/Assets/Prefabs/UI/CharacterSelect/CharacterSelect.prefab b/DarkFlow/Assets/Prefabs/UI/CharacterSelect/CharacterSelect.prefab index 9e7cecb..8220a7f 100644 --- a/DarkFlow/Assets/Prefabs/UI/CharacterSelect/CharacterSelect.prefab +++ b/DarkFlow/Assets/Prefabs/UI/CharacterSelect/CharacterSelect.prefab @@ -184,7 +184,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3} m_Name: m_EditorClassIdentifier: - GlobalObjectIdHash: 2731206212 + GlobalObjectIdHash: 3279208134 AlwaysReplicateAsRoot: 0 SynchronizeTransform: 1 ActiveSceneSynchronization: 0 diff --git a/DarkFlow/Assets/Resources/SynchedServerData.prefab b/DarkFlow/Assets/Resources/SynchedServerData.prefab index 0b8400a..0dc2489 100644 --- a/DarkFlow/Assets/Resources/SynchedServerData.prefab +++ b/DarkFlow/Assets/Resources/SynchedServerData.prefab @@ -25,13 +25,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 6821460796240439114} + 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: [] m_Father: {fileID: 0} - m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &6821460796240439115 MonoBehaviour: @@ -45,8 +45,12 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3} m_Name: m_EditorClassIdentifier: - GlobalObjectIdHash: 951099334 + GlobalObjectIdHash: 1607073199 AlwaysReplicateAsRoot: 0 + SynchronizeTransform: 1 + ActiveSceneSynchronization: 0 + SceneMigrationSynchronization: 1 + SpawnWithObservers: 1 DontDestroyWithOwner: 0 AutoObjectParentSync: 1 --- !u!114 &6821460796240439117 diff --git a/DarkFlow/Assets/Prefabs/GameObject.prefab.meta b/DarkFlow/Assets/Samples.meta similarity index 57% rename from DarkFlow/Assets/Prefabs/GameObject.prefab.meta rename to DarkFlow/Assets/Samples.meta index b097d18..a679cd9 100644 --- a/DarkFlow/Assets/Prefabs/GameObject.prefab.meta +++ b/DarkFlow/Assets/Samples.meta @@ -1,6 +1,7 @@ fileFormatVersion: 2 -guid: 91b0679f4a616254ab5aa7626bde8851 -PrefabImporter: +guid: a763149750b4f2a409092c01c088a082 +folderAsset: yes +DefaultImporter: externalObjects: {} userData: assetBundleName: diff --git a/DarkFlow/Assets/Samples/Multiplayer Tools.meta b/DarkFlow/Assets/Samples/Multiplayer Tools.meta new file mode 100644 index 0000000..75105e4 --- /dev/null +++ b/DarkFlow/Assets/Samples/Multiplayer Tools.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a73ee4bffee598d428a24704ecf68baa +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5.meta b/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5.meta new file mode 100644 index 0000000..92dab6b --- /dev/null +++ b/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7208c38c0006fea45be737e870b53250 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples.meta b/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples.meta new file mode 100644 index 0000000..d182547 --- /dev/null +++ b/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c81a4cce39bc4784991c5d50a5d9bada +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/.sample.json b/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/.sample.json new file mode 100644 index 0000000..c8abf89 --- /dev/null +++ b/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/.sample.json @@ -0,0 +1,4 @@ +{ + "displayName": "Network Scenario Samples", + "description": "Samples showcasing the different ways of building custom network simulator scenarios." +} \ No newline at end of file diff --git a/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/ConnectionParametersWithCurves.cs b/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/ConnectionParametersWithCurves.cs new file mode 100644 index 0000000..c4fba4e --- /dev/null +++ b/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/ConnectionParametersWithCurves.cs @@ -0,0 +1,79 @@ +using System; +using Unity.Multiplayer.Tools.NetworkSimulator.Runtime; +using UnityEngine; + +namespace Unity.Multiplayer.Tools.Samples.NetworkScenario +{ + [Serializable] + public class ConnectionParametersWithCurves : NetworkScenarioBehaviour + { + [SerializeField] + float m_LoopDurationMilliseconds = 10f; + + [SerializeField] + AnimationCurve m_PacketDelayMilliseconds = new(default, new(.5f, 100f), new(1f, 0f)); + + [SerializeField] + AnimationCurve m_PacketJitterMilliseconds = new(default, new(.5f, 50f), new(1f, 0f)); + + [SerializeField] + AnimationCurve m_PacketLossInterval = AnimationCurve.Constant(0f, 1f, 0f); + + [SerializeField] + AnimationCurve m_PacketLossPercent = new(default, new(.5f, 3f), new(1f, 0f)); + + INetworkEventsApi m_NetworkEventsApi; + INetworkSimulatorPreset m_CustomPreset; + INetworkSimulatorPreset m_DefaultPreset; + float m_ElapsedTime; + + public override void Start(INetworkEventsApi networkEventsApi) + { + // Keep a reference to the NetworkEventsApi so then we can change the preset in the update. + m_NetworkEventsApi = networkEventsApi; + + // Store the current preset so then we can revert once the scenario finishes. + m_DefaultPreset = m_NetworkEventsApi.CurrentPreset; + + // Create a custom preset so then we can change the parameters. + m_CustomPreset = NetworkSimulatorPreset.Create(nameof(ConnectionParametersWithCurves)); + + UpdateParameters(); + } + + protected override void Update(float deltaTime) + { + // Calculate the elapsed time for the current loop. + m_ElapsedTime += deltaTime; + + // Once the elapsed time passes the duration, resets it keeping track of any extra milliseconds. + if (m_ElapsedTime >= m_LoopDurationMilliseconds) + { + m_ElapsedTime -= m_LoopDurationMilliseconds; + } + + UpdateParameters(); + } + + void UpdateParameters() + { + // Calculates the progress of the current loop based on the time elapsed. + var progress = m_ElapsedTime / m_LoopDurationMilliseconds; + + // Update all curves based on the loop progress. + m_CustomPreset.PacketDelayMs = (int)m_PacketDelayMilliseconds.Evaluate(progress); + m_CustomPreset.PacketJitterMs = (int)m_PacketJitterMilliseconds.Evaluate(progress); + m_CustomPreset.PacketLossInterval = (int)m_PacketLossInterval.Evaluate(progress); + m_CustomPreset.PacketLossPercent = (int)m_PacketLossPercent.Evaluate(progress); + + // Apply the changed parameters using the NetworkEventsApi. + m_NetworkEventsApi.ChangeConnectionPreset(m_CustomPreset); + } + + public override void Dispose() + { + // After finishing the current scenario, reset preset to the previous value if there were one. + m_NetworkEventsApi.ChangeConnectionPreset(m_DefaultPreset); + } + } +} diff --git a/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/ConnectionParametersWithCurves.cs.meta b/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/ConnectionParametersWithCurves.cs.meta new file mode 100644 index 0000000..8e73ca9 --- /dev/null +++ b/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/ConnectionParametersWithCurves.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 66b40e4ba8f34bf18488be17b9a103b0 +timeCreated: 1665613953 \ No newline at end of file diff --git a/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/DisconnectScenarioWithMonoBehaviour.cs b/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/DisconnectScenarioWithMonoBehaviour.cs new file mode 100644 index 0000000..3af7be6 --- /dev/null +++ b/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/DisconnectScenarioWithMonoBehaviour.cs @@ -0,0 +1,38 @@ +using Unity.Multiplayer.Tools.NetworkSimulator.Runtime; + +namespace Unity.Multiplayer.Tools.Samples.NetworkScenario +{ + public class DisconnectScenarioWithMonoBehaviour : NetworkScenarioBehaviour + { + const float m_DeltaTimeBetweenEvents = 1000f; + + INetworkEventsApi m_NetworkEventsApi; + float m_ElapsedTime; + + public override void Start(INetworkEventsApi networkEventsApi) + { + m_NetworkEventsApi = networkEventsApi; + } + + protected override void Update(float deltaTime) + { + m_ElapsedTime += deltaTime; + + if (m_ElapsedTime < m_DeltaTimeBetweenEvents) + { + return; + } + + m_ElapsedTime -= m_DeltaTimeBetweenEvents; + + if (m_NetworkEventsApi.IsConnected) + { + m_NetworkEventsApi.Disconnect(); + } + else + { + m_NetworkEventsApi.Reconnect(); + } + } + } +} diff --git a/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/DisconnectScenarioWithMonoBehaviour.cs.meta b/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/DisconnectScenarioWithMonoBehaviour.cs.meta new file mode 100644 index 0000000..ce8134e --- /dev/null +++ b/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/DisconnectScenarioWithMonoBehaviour.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 602cadce199df0e48a24ec5ace12072e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/LagSpikeScenarioWithAsyncTask.cs b/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/LagSpikeScenarioWithAsyncTask.cs new file mode 100644 index 0000000..b043041 --- /dev/null +++ b/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/LagSpikeScenarioWithAsyncTask.cs @@ -0,0 +1,35 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Unity.Multiplayer.Tools.NetworkSimulator.Runtime; +using UnityEngine; + +namespace Unity.Multiplayer.Tools.Samples.NetworkScenario +{ + public class LagSpikeScenarioWithAsyncTask : NetworkScenarioTask + { + [SerializeField] + int m_DurationBetweenLagSpikesMilliseconds; + + [SerializeField] + int m_LagSpikeDurationMilliseconds; + + protected override async Task Run(INetworkEventsApi networkEventsApi, CancellationToken cancellationToken) + { + while (cancellationToken.IsCancellationRequested == false) + { + await Task.Delay(TimeSpan.FromMilliseconds(m_DurationBetweenLagSpikesMilliseconds), cancellationToken); + + // Make sure to check if the user paused the scenario. This isn't pausing all waiting behavior + // but will skip the lag spike, which is essentially the behavior we want to avoid when paused. + if (IsPaused) + { + await Task.Yield(); + continue; + } + + await networkEventsApi.TriggerLagSpikeAsync(TimeSpan.FromMilliseconds(m_LagSpikeDurationMilliseconds)); + } + } + } +} diff --git a/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/LagSpikeScenarioWithAsyncTask.cs.meta b/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/LagSpikeScenarioWithAsyncTask.cs.meta new file mode 100644 index 0000000..15b8ff7 --- /dev/null +++ b/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/LagSpikeScenarioWithAsyncTask.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 373efa4d5a90c2648880ca8d3ef28119 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/Samples.NetworkScenarios.asmdef b/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/Samples.NetworkScenarios.asmdef new file mode 100644 index 0000000..e9f1237 --- /dev/null +++ b/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/Samples.NetworkScenarios.asmdef @@ -0,0 +1,22 @@ +{ + "name": "Samples.NetworkScenarios", + "rootNamespace": "Unity.Multiplayer.Tools.Samples.NetworkScenario", + "defineConstraints": [ + "UNITY_2022_2_OR_NEWER", + "UTP_TRANSPORT_2_0_ABOVE", + "UNITY_NETCODE_GAMEOBJECTS_1_1_ABOVE" + ], + "versionDefines": [ + { + "name": "com.unity.transport", + "expression": "2.0.0-exp", + "define": "UTP_TRANSPORT_2_0_ABOVE" + }, + { + "name": "com.unity.netcode.gameobjects", + "expression": "1.1.0", + "define": "UNITY_NETCODE_GAMEOBJECTS_1_1_ABOVE" + } + ], + "references":[ "Unity.Multiplayer.Tools.NetworkSimulator.Runtime" ] +} \ No newline at end of file diff --git a/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/Samples.NetworkScenarios.asmdef.meta b/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/Samples.NetworkScenarios.asmdef.meta new file mode 100644 index 0000000..0279e2f --- /dev/null +++ b/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/Samples.NetworkScenarios.asmdef.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1e1daa6acb0a4017adab54aa23a1d1bc +timeCreated: 1682980748 \ No newline at end of file diff --git a/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/UnstableConnection.cs b/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/UnstableConnection.cs new file mode 100644 index 0000000..5d4c29b --- /dev/null +++ b/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/UnstableConnection.cs @@ -0,0 +1,254 @@ +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using JetBrains.Annotations; +using Unity.Multiplayer.Tools.NetworkSimulator.Runtime; +using UnityEngine; +using Random = System.Random; + +namespace Unity.Multiplayer.Tools.Samples.NetworkScenario +{ + [UsedImplicitly, Serializable] + public class UnstableConnection : NetworkScenarioTask + { +#region Scenario Event Configuration classes + [Serializable] + abstract class EventConfiguration + { + [SerializeField] + [Tooltip("Toggle to activate this type of event.")] + bool m_Active; + + internal bool IsActive => m_Active; + + internal abstract void Activate(INetworkEventsApi networkEventsApi, UnstableConnection scenario); + } + + [Serializable] + class LagSpikeConfiguration : EventConfiguration + { + [SerializeField, MinMaxRange(0, 5000, true)] + [Tooltip("Time range (in milliseconds) the lag spike will last.")] + Vector2 m_TimeRangeInMs = new(0, 5000); + + internal override void Activate(INetworkEventsApi networkEventsApi, UnstableConnection scenario) + { + var timeSpan = TimeSpan.FromMilliseconds(scenario.Randomizer.Next((int)m_TimeRangeInMs.x, (int)m_TimeRangeInMs.y)); + networkEventsApi.TriggerLagSpike(timeSpan); + } + } + + [Serializable] + class PacketDelayConfiguration : EventConfiguration + { + [SerializeField, MinMaxRange(0, 5000, true)] + [Tooltip("Delay range (in milliseconds) that will be added to the simulator configuration.")] + Vector2 m_DelayRangeInMs = new(50, 150); + + internal override void Activate(INetworkEventsApi _, UnstableConnection scenario) + { + if (scenario.ShouldResetBetweenEvents) + { + scenario.ResetScenarioConfiguration(); + } + + scenario.ScenarioConfiguration.PacketDelayMs = scenario.Randomizer.Next((int)m_DelayRangeInMs.x, (int)m_DelayRangeInMs.y); + } + } + + [Serializable] + class PacketJitterConfiguration : EventConfiguration + { + [SerializeField, MinMaxRange(0, 5000, true)] + [Tooltip("Jitter range (in milliseconds) that will be added to the simulator configuration.")] + Vector2 m_JitterRangeInMs = new(50, 100); + + internal override void Activate(INetworkEventsApi _, UnstableConnection scenario) + { + if (scenario.ShouldResetBetweenEvents) + { + scenario.ResetScenarioConfiguration(); + } + + scenario.ScenarioConfiguration.PacketJitterMs = scenario.Randomizer.Next((int)m_JitterRangeInMs.x, (int)m_JitterRangeInMs.y); + } + } + + [Serializable] + class PacketLossConfiguration : EventConfiguration + { + [SerializeField, MinMaxRange(0, 100, true)] + [Tooltip("Packet loss percentage range that will be set in the simulator configuration. Minimum is 0. Maximum is 100.")] + Vector2 m_PacketLossRangeInPercent = new(0, 10); + + internal override void Activate(INetworkEventsApi _, UnstableConnection scenario) + { + if (scenario.ShouldResetBetweenEvents) + { + scenario.ResetScenarioConfiguration(); + } + + scenario.ScenarioConfiguration.PacketLossPercent = scenario.Randomizer.Next((int)m_PacketLossRangeInPercent.x, (int)m_PacketLossRangeInPercent.y); + } + } + + [Serializable] + class PacketLossIntervalConfiguration : EventConfiguration + { + [SerializeField, MinMaxRange(0, 9999, true)] + [Tooltip("Packet loss range interval that will be set in the simulator configuration.")] + Vector2 m_MinimumInterval = new(0, 0); + + internal override void Activate(INetworkEventsApi _, UnstableConnection scenario) + { + if (scenario.ShouldResetBetweenEvents) + { + scenario.ResetScenarioConfiguration(); + } + + scenario.ScenarioConfiguration.PacketLossInterval = scenario.Randomizer.Next((int)m_MinimumInterval.x, (int)m_MinimumInterval.y); + } + } +#endregion + + [SerializeField, Min(0)] + [Tooltip("Minimum time (in milliseconds) before an event happen. No event will happen until this amount of time has passed.")] + int m_MinimumWaitTimeMs = 3000; + + [SerializeField, Min(0)] + [Tooltip("Maximum time (in milliseconds) before an event happen. If it goes beyond that, an event will happen automatically.")] + int m_MaximumWaitTimeMs = 5000; + + [SerializeField, Range(0, 100)] + [Tooltip("How often should an event occur.")] + int m_EventFrequency = 50; + + [SerializeField] + [Tooltip("Seed to use for the randomizer. If set to -1, the default seed by System.Random is used.")] + int m_RandomizerSeed = -1; + + [SerializeField, Range(1, 5)] + [Tooltip("How many events should occur at a time. Events will not repeat each other on the same trigger.")] + int m_EventCount = 1; + + [SerializeField] + [Tooltip("Should the network configuration reset between events. If toggled, every new trigger will start from a clean slate." + + "If not toggled, every new trigger will change the current configuration.")] + bool m_ResetConfigurationBetweenEvents; + + [SerializeField] + LagSpikeConfiguration m_LagSpikeConfiguration = new(); + + [SerializeField] + PacketDelayConfiguration m_PacketDelayConfiguration = new(); + + [SerializeField] + PacketJitterConfiguration m_PacketJitterConfiguration = new(); + + [SerializeField] + PacketLossConfiguration m_PacketLossConfiguration = new(); + + [SerializeField] + PacketLossIntervalConfiguration m_PacketLossIntervalConfiguration = new(); + + INetworkSimulatorPreset m_SimulatorCache; + bool m_IsFirstEventOfTrigger; + + internal Random Randomizer { get; private set; } + internal INetworkSimulatorPreset ScenarioConfiguration { get; private set; } + internal bool ShouldResetBetweenEvents => m_ResetConfigurationBetweenEvents && m_IsFirstEventOfTrigger; + + EventConfiguration[] m_EventConfigurations; + + protected override async Task Run(INetworkEventsApi networkEventsApi, CancellationToken cancellationToken) + { + m_EventConfigurations = new EventConfiguration[] + { + m_LagSpikeConfiguration, + m_PacketDelayConfiguration, + m_PacketJitterConfiguration, + m_PacketLossConfiguration, + m_PacketLossIntervalConfiguration + }; + + Randomizer = m_RandomizerSeed == -1 + ? new Random() + : new Random(m_RandomizerSeed); + + m_SimulatorCache = networkEventsApi.CurrentPreset; + + ResetScenarioConfiguration(); + var lastTriggerTime = 0f; + + try + { + while (cancellationToken.IsCancellationRequested == false) + { + if (IsPaused) + { + await Task.Yield(); + continue; + } + + var shouldDoSomething = lastTriggerTime > m_MinimumWaitTimeMs && + (Randomizer.Next(0, 100) < m_EventFrequency + || lastTriggerTime > m_MaximumWaitTimeMs); + + if (shouldDoSomething) + { + await TriggerNetworkEvents(networkEventsApi, cancellationToken); + lastTriggerTime = m_MinimumWaitTimeMs; + await Task.Delay(m_MinimumWaitTimeMs, cancellationToken); + } + else + { + lastTriggerTime += Time.deltaTime * 1000; + await Task.Yield(); + } + } + } + finally + { + //Setting back the original preset at the end of the scenario + networkEventsApi.ChangeConnectionPreset(m_SimulatorCache); + } + } + + internal void ResetScenarioConfiguration() + { + ScenarioConfiguration = NetworkSimulatorPreset.Create("Unstable Connection Configuration", + packetDelayMs: m_SimulatorCache.PacketDelayMs, + packetJitterMs: m_SimulatorCache.PacketJitterMs, + packetLossPercent: m_SimulatorCache.PacketLossPercent, + packetLossInterval: m_SimulatorCache.PacketLossInterval); + } + + async Task TriggerNetworkEvents(INetworkEventsApi networkEventsApi, CancellationToken cancellationToken) + { + var activeConfigurations = m_EventConfigurations.Where(x => x?.IsActive ?? false).ToList(); + + if (activeConfigurations.Count == 0) + { + Debug.Log("No Active Configurations"); + await Task.Yield(); + return; + } + + var eventCount = m_EventCount > activeConfigurations.Count ? activeConfigurations.Count : m_EventCount; + + m_IsFirstEventOfTrigger = true; + while (eventCount > 0) + { + var configIndex = Randomizer.Next(0, activeConfigurations.Count); + var configuration = activeConfigurations.ToList()[configIndex]; + configuration.Activate(networkEventsApi, this); + activeConfigurations.Remove(configuration); + --eventCount; + m_IsFirstEventOfTrigger = false; + } + + networkEventsApi.ChangeConnectionPreset(ScenarioConfiguration); + } + } +} diff --git a/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/UnstableConnection.cs.meta b/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/UnstableConnection.cs.meta new file mode 100644 index 0000000..c3ab4d8 --- /dev/null +++ b/DarkFlow/Assets/Samples/Multiplayer Tools/2.0.0-pre.5/Network Scenario Samples/UnstableConnection.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b4c51d688f024ba28b06be372625e386 +timeCreated: 1664910675 \ No newline at end of file diff --git a/DarkFlow/Assets/Scenes/Bootstrap.unity b/DarkFlow/Assets/Scenes/Bootstrap.unity index 6766b5b..3fbd6ab 100644 --- a/DarkFlow/Assets/Scenes/Bootstrap.unity +++ b/DarkFlow/Assets/Scenes/Bootstrap.unity @@ -270,7 +270,7 @@ GameObject: m_Component: - component: {fileID: 946481244} - component: {fileID: 946481243} - - component: {fileID: 946481242} + - component: {fileID: 946481245} m_Layer: 0 m_Name: EventSystem m_TagString: Untagged @@ -278,26 +278,6 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!114 &946481242 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 946481241} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3} - m_Name: - m_EditorClassIdentifier: - m_SendPointerHoverToParent: 1 - m_HorizontalAxis: Horizontal - m_VerticalAxis: Vertical - m_SubmitButton: Submit - m_CancelButton: Cancel - m_InputActionsPerSecond: 10 - m_RepeatDelay: 0.5 - m_ForceModuleActive: 0 --- !u!114 &946481243 MonoBehaviour: m_ObjectHideFlags: 0 @@ -328,6 +308,47 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &946481245 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 946481241} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SendPointerHoverToParent: 1 + m_MoveRepeatDelay: 0.5 + m_MoveRepeatRate: 0.1 + m_XRTrackingOrigin: {fileID: 0} + m_ActionsAsset: {fileID: -944628639613478452, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_PointAction: {fileID: -1654692200621890270, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_MoveAction: {fileID: -8784545083839296357, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_SubmitAction: {fileID: 392368643174621059, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_CancelAction: {fileID: 7727032971491509709, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_LeftClickAction: {fileID: 3001919216989983466, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_MiddleClickAction: {fileID: -2185481485913320682, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_RightClickAction: {fileID: -4090225696740746782, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_ScrollWheelAction: {fileID: 6240969308177333660, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_TrackedDevicePositionAction: {fileID: 6564999863303420839, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_TrackedDeviceOrientationAction: {fileID: 7970375526676320489, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_DeselectOnBackgroundClick: 1 + m_PointerBehavior: 0 + m_CursorLockBehavior: 0 --- !u!1 &1214702237 GameObject: m_ObjectHideFlags: 0 @@ -516,7 +537,7 @@ PrefabInstance: - target: {fileID: 6485963998722371857, guid: d3062ecfb0bd4bf4da5e175e5a3e2e8f, type: 3} propertyPath: m_ProtocolType - value: 0 + value: 1 objectReference: {fileID: 0} - target: {fileID: 6485963998722371857, guid: d3062ecfb0bd4bf4da5e175e5a3e2e8f, type: 3} @@ -593,6 +614,11 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: 6485963998722371871, guid: d3062ecfb0bd4bf4da5e175e5a3e2e8f, + type: 3} + propertyPath: LogLevel + value: 0 + objectReference: {fileID: 0} - target: {fileID: 6485963998722371871, guid: d3062ecfb0bd4bf4da5e175e5a3e2e8f, type: 3} propertyPath: NetworkConfig.PlayerPrefab diff --git a/DarkFlow/Assets/Scenes/Gameplay.unity b/DarkFlow/Assets/Scenes/Gameplay.unity index 7fcad41..d4eecc8 100644 --- a/DarkFlow/Assets/Scenes/Gameplay.unity +++ b/DarkFlow/Assets/Scenes/Gameplay.unity @@ -125,6 +125,60 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &99000313 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 99000315} + - component: {fileID: 99000314} + m_Layer: 0 + m_Name: Runtime Network Stats Monitor + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &99000314 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 99000313} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 17737e0516da2445b9b0077ae2bd9b4f, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Visible: 1 + m_MaxRefreshRate: 30 + k__BackingField: {fileID: 0} + k__BackingField: {fileID: 0} + k__BackingField: + k__BackingField: 1 + m_PositionLeftToRight: 0 + m_PositionTopToBottom: 0 + k__BackingField: {fileID: 11400000, guid: 8f1b4e3792d8446399527749cfb591a2, + type: 2} +--- !u!4 &99000315 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 99000313} + 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: 1 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &107306944 stripped GameObject: m_CorrespondingSourceObject: {fileID: 3984814823395178536, guid: 773b39ed367c011418f28a8bc3b8ca31, @@ -155,7 +209,7 @@ MonoBehaviour: CameraRadius: 0.2 DampingIntoCollision: 0 DampingFromCollision: 2 ---- !u!1 &825465017 +--- !u!1 &788959708 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -163,29 +217,87 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 825465018} + - component: {fileID: 788959709} + - component: {fileID: 788959710} + - component: {fileID: 788959711} m_Layer: 0 - m_Name: Point (2) + m_Name: EventSystem m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!4 &825465018 +--- !u!4 &788959709 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 825465017} + m_GameObject: {fileID: 788959708} serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 3, y: 0, z: 0} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 1 m_Children: [] - m_Father: {fileID: 2121872605} + m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &788959710 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 788959708} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_FirstSelected: {fileID: 0} + m_sendNavigationEvents: 1 + m_DragThreshold: 10 +--- !u!114 &788959711 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 788959708} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SendPointerHoverToParent: 1 + m_MoveRepeatDelay: 0.5 + m_MoveRepeatRate: 0.1 + m_XRTrackingOrigin: {fileID: 0} + m_ActionsAsset: {fileID: -944628639613478452, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_PointAction: {fileID: -1654692200621890270, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_MoveAction: {fileID: -8784545083839296357, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_SubmitAction: {fileID: 392368643174621059, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_CancelAction: {fileID: 7727032971491509709, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_LeftClickAction: {fileID: 3001919216989983466, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_MiddleClickAction: {fileID: -2185481485913320682, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_RightClickAction: {fileID: -4090225696740746782, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_ScrollWheelAction: {fileID: 6240969308177333660, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_TrackedDevicePositionAction: {fileID: 6564999863303420839, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_TrackedDeviceOrientationAction: {fileID: 7970375526676320489, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_DeselectOnBackgroundClick: 1 + m_PointerBehavior: 0 + m_CursorLockBehavior: 0 --- !u!1001 &898180339 PrefabInstance: m_ObjectHideFlags: 0 @@ -199,11 +311,6 @@ PrefabInstance: propertyPath: m_Name value: EnvironmentMain objectReference: {fileID: 0} - - target: {fileID: 3845101940633919540, guid: f66c914e9473afe4796ff1424867c0a5, - type: 3} - propertyPath: m_IsActive - value: 1 - objectReference: {fileID: 0} - target: {fileID: 4474145340166388366, guid: f66c914e9473afe4796ff1424867c0a5, type: 3} propertyPath: m_LocalPosition.x @@ -254,57 +361,11 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} - - target: {fileID: 8609971574843151533, guid: f66c914e9473afe4796ff1424867c0a5, - type: 3} - propertyPath: m_LocalPosition.x - value: 1.07 - objectReference: {fileID: 0} - - target: {fileID: 8609971574843151533, guid: f66c914e9473afe4796ff1424867c0a5, - type: 3} - propertyPath: m_LocalPosition.y - value: 0.49 - objectReference: {fileID: 0} - - target: {fileID: 8609971574843151533, guid: f66c914e9473afe4796ff1424867c0a5, - type: 3} - propertyPath: m_LocalPosition.z - value: -5.02 - objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: f66c914e9473afe4796ff1424867c0a5, type: 3} ---- !u!1 &1022041805 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1022041806} - m_Layer: 0 - m_Name: Point (3) - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &1022041806 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1022041805} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 1.94, y: 0, z: 1.01} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 1 - m_Children: [] - m_Father: {fileID: 2121872605} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &1058292731 PrefabInstance: m_ObjectHideFlags: 0 @@ -408,37 +469,6 @@ PrefabInstance: m_AddedGameObjects: [] m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 154519ab488f20d468de4e06396e2441, type: 3} ---- !u!1 &1367546626 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1367546627} - m_Layer: 0 - m_Name: Point - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &1367546627 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1367546626} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -2.43, y: 0, z: 5.15} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 1 - m_Children: [] - m_Father: {fileID: 2121872605} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!4 &1391518848 stripped Transform: m_CorrespondingSourceObject: {fileID: 7539522792964821713, guid: a4c43bf8901061a40a02054aba85ff81, @@ -563,37 +593,6 @@ MonoBehaviour: m_LightCookieSize: {x: 1, y: 1} m_LightCookieOffset: {x: 0, y: 0} m_SoftShadowQuality: 0 ---- !u!1 &1718297848 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1718297849} - m_Layer: 0 - m_Name: Point (1) - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &1718297849 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1718297848} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -3.22} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 1 - m_Children: [] - m_Father: {fileID: 2121872605} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &1889354785 PrefabInstance: m_ObjectHideFlags: 0 @@ -691,59 +690,6 @@ PrefabInstance: insertIndex: -1 addedObject: {fileID: 107306948} m_SourcePrefab: {fileID: 100100000, guid: 773b39ed367c011418f28a8bc3b8ca31, type: 3} ---- !u!1 &2121872603 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 2121872605} - - component: {fileID: 2121872604} - m_Layer: 0 - m_Name: PlayerSpawnPoints - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &2121872604 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2121872603} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 756fbc7dbb18d7844b49d5d3d646c911, type: 3} - m_Name: - m_EditorClassIdentifier: - m_SpawnPoints: - - {fileID: 1367546626} - - {fileID: 1718297848} - - {fileID: 825465017} - - {fileID: 1022041805} ---- !u!4 &2121872605 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2121872603} - 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: 1 - m_Children: - - {fileID: 1367546627} - - {fileID: 1718297849} - - {fileID: 825465018} - - {fileID: 1022041806} - m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &7539522792693849209 PrefabInstance: m_ObjectHideFlags: 0 @@ -752,6 +698,11 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 0} m_Modifications: + - target: {fileID: 7539522792693849211, guid: a4c43bf8901061a40a02054aba85ff81, + type: 3} + propertyPath: m_Enabled + value: 1 + objectReference: {fileID: 0} - target: {fileID: 7539522792693849211, guid: a4c43bf8901061a40a02054aba85ff81, type: 3} propertyPath: GlobalObjectIdHash @@ -770,32 +721,32 @@ PrefabInstance: - target: {fileID: 7539522792964821713, guid: a4c43bf8901061a40a02054aba85ff81, type: 3} propertyPath: m_LocalPosition.y - value: 0.56 + value: 1.45 objectReference: {fileID: 0} - target: {fileID: 7539522792964821713, guid: a4c43bf8901061a40a02054aba85ff81, type: 3} propertyPath: m_LocalPosition.z - value: -2.16 + value: -3.06 objectReference: {fileID: 0} - target: {fileID: 7539522792964821713, guid: a4c43bf8901061a40a02054aba85ff81, type: 3} propertyPath: m_LocalRotation.w - value: 0 + value: 1 objectReference: {fileID: 0} - target: {fileID: 7539522792964821713, guid: a4c43bf8901061a40a02054aba85ff81, type: 3} propertyPath: m_LocalRotation.x - value: -0 + value: 0 objectReference: {fileID: 0} - target: {fileID: 7539522792964821713, guid: a4c43bf8901061a40a02054aba85ff81, type: 3} propertyPath: m_LocalRotation.y - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 7539522792964821713, guid: a4c43bf8901061a40a02054aba85ff81, type: 3} propertyPath: m_LocalRotation.z - value: -0 + value: 0 objectReference: {fileID: 0} - target: {fileID: 7539522792964821713, guid: a4c43bf8901061a40a02054aba85ff81, type: 3} @@ -805,7 +756,7 @@ PrefabInstance: - target: {fileID: 7539522792964821713, guid: a4c43bf8901061a40a02054aba85ff81, type: 3} propertyPath: m_LocalEulerAnglesHint.y - value: 180 + value: 0 objectReference: {fileID: 0} - target: {fileID: 7539522792964821713, guid: a4c43bf8901061a40a02054aba85ff81, type: 3} @@ -836,9 +787,10 @@ PrefabInstance: SceneRoots: m_ObjectHideFlags: 0 m_Roots: - - {fileID: 7539522792693849209} - {fileID: 1549843939} - - {fileID: 2121872605} + - {fileID: 7539522792693849209} - {fileID: 898180339} - {fileID: 1058292731} - {fileID: 1889354785} + - {fileID: 788959709} + - {fileID: 99000315} diff --git a/DarkFlow/Assets/Scripts/CharacterSpawner.cs b/DarkFlow/Assets/Scripts/CharacterSpawner.cs index 95bcf12..4111024 100644 --- a/DarkFlow/Assets/Scripts/CharacterSpawner.cs +++ b/DarkFlow/Assets/Scripts/CharacterSpawner.cs @@ -3,14 +3,19 @@ using Unity.Netcode; using UnityEngine; +[DefaultExecutionOrder(0)] // before client component public class CharacterSpawner : NetworkBehaviour { [Header("References")] [SerializeField] private CharacterDatabase characterDatabase; - [SerializeField] private Transform spawnPos; public override void OnNetworkSpawn() + { + OnServerSpawnPlayer(); + } + + void OnServerSpawnPlayer() { if (!IsServer) { return; } @@ -19,9 +24,8 @@ public override void OnNetworkSpawn() var character = characterDatabase.GetCharacterById(client.Value.characterId); if (character != null) { - //var spawnPos = new Vector3(Random.Range(-3f, 3f), 0f, Random.Range(-3f, 3f)); - //var characterInstance = Instantiate(character.GameplayPrefab, spawnPos, Quaternion.identity); - var characterInstance = Instantiate(character.GameplayPrefab, spawnPos); + var spawnPos = new Vector3(Random.Range(-3f, 3f), 0f, Random.Range(-3f, 3f)); + var characterInstance = Instantiate(character.GameplayPrefab, spawnPos, Quaternion.identity); characterInstance.SpawnAsPlayerObject(client.Value.clientId); } } diff --git a/DarkFlow/Assets/Scripts/ClientNetworkAnimator.cs b/DarkFlow/Assets/Scripts/ClientNetworkAnimator.cs index 39b98f5..a724f0e 100644 --- a/DarkFlow/Assets/Scripts/ClientNetworkAnimator.cs +++ b/DarkFlow/Assets/Scripts/ClientNetworkAnimator.cs @@ -6,7 +6,6 @@ [DisallowMultipleComponent] public class ClientNetworkAnimator : NetworkAnimator { - protected override bool OnIsServerAuthoritative() { return false; diff --git a/DarkFlow/Assets/Scripts/ClientPlayerMove.cs b/DarkFlow/Assets/Scripts/ClientPlayerMove.cs deleted file mode 100644 index 1a3b24b..0000000 --- a/DarkFlow/Assets/Scripts/ClientPlayerMove.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; -using Cinemachine; -using StarterAssets; -using Unity.Netcode; -using UnityEngine; -using UnityEngine.InputSystem; - -/// -/// Assumes client authority -/// -[RequireComponent(typeof(ServerPlayerMove))] -[DefaultExecutionOrder(1)] // after server component -public class ClientPlayerMove : NetworkBehaviour -{ - [SerializeField] - ServerPlayerMove m_ServerPlayerMove; - - [SerializeField] - CharacterController m_CharacterController; - - [SerializeField] - ThirdPersonController m_ThirdPersonController; - - [SerializeField] - Transform m_CameraFollow; - - [SerializeField] - PlayerInput m_PlayerInput; - - void Awake() - { - Cursor.lockState = CursorLockMode.Locked; - Cursor.visible = false; - - // ThirdPersonController & CharacterController are enabled only on owning clients. Ghost player objects have - // these two components disabled, and will enable a CapsuleCollider. Per the CharacterController documentation: - // https://docs.unity3d.com/Manual/CharacterControllers.html, a Character controller can push rigidbody - // objects aside while moving but will not be accelerated by incoming collisions. This means that a primitive - // CapsuleCollider must instead be used for ghost clients to simulate collisions between owning players and - // ghost clients. - m_ThirdPersonController.enabled = false; - m_CharacterController.enabled = false; - } - - public override void OnNetworkSpawn() - { - base.OnNetworkSpawn(); - - enabled = IsClient; - if (!IsOwner) - { - enabled = false; - m_CharacterController.enabled = false; - return; - } - - // player input is only enabled on owning players - m_PlayerInput.enabled = true; - m_ThirdPersonController.enabled = true; - - // see the note inside ServerPlayerMove why this step is also necessary for synchronizing initial player - // position on owning clients - m_CharacterController.enabled = true; - - var cinemachineVirtualCamera = FindObjectOfType(); - cinemachineVirtualCamera.Follow = m_CameraFollow; - } - - -} diff --git a/DarkFlow/Assets/Scripts/ClientPlayerSetings.cs b/DarkFlow/Assets/Scripts/ClientPlayerSetings.cs new file mode 100644 index 0000000..723d83c --- /dev/null +++ b/DarkFlow/Assets/Scripts/ClientPlayerSetings.cs @@ -0,0 +1,42 @@ +using System; +using Cinemachine; +using StarterAssets; +using Unity.Netcode; +using UnityEngine; +using UnityEngine.InputSystem; + +/// Assumes client authority +[DefaultExecutionOrder(1)] // after server component +public class ClientPlayerSetings : NetworkBehaviour +{ + + [SerializeField] + CharacterController m_CharacterController; + + [SerializeField] + ThirdPersonController m_ThirdPersonController; + + [SerializeField] + Transform m_CameraFollow; + + [SerializeField] + PlayerInput m_PlayerInput; + + public override void OnNetworkSpawn() + { + Debug.Log(".......... ClientPlayerSeting1"); + if (!IsOwner) { return; } + + // player input is only enabled on owning players + m_PlayerInput.enabled = true; + m_ThirdPersonController.enabled = true; + m_CharacterController.enabled = true; + + //var cinemachineVirtualCamera = FindObjectOfType(); + //cinemachineVirtualCamera.Follow = m_CameraFollow; + FindObjectOfType().Follow = m_CameraFollow; + Debug.Log(".......... ClientPlayerSeting2"); + } + + +} diff --git a/DarkFlow/Assets/Scripts/ClientPlayerMove.cs.meta b/DarkFlow/Assets/Scripts/ClientPlayerSetings.cs.meta similarity index 100% rename from DarkFlow/Assets/Scripts/ClientPlayerMove.cs.meta rename to DarkFlow/Assets/Scripts/ClientPlayerSetings.cs.meta diff --git a/DarkFlow/Assets/Scripts/InputSystem/StarterAssetsInputs.cs b/DarkFlow/Assets/Scripts/InputSystem/StarterAssetsInputs.cs index d1aa157..c3ffcd5 100644 --- a/DarkFlow/Assets/Scripts/InputSystem/StarterAssetsInputs.cs +++ b/DarkFlow/Assets/Scripts/InputSystem/StarterAssetsInputs.cs @@ -1,5 +1,5 @@ using UnityEngine; -#if ENABLE_INPUT_SYSTEM && STARTER_ASSETS_PACKAGES_CHECKED +#if ENABLE_INPUT_SYSTEM using UnityEngine.InputSystem; #endif @@ -20,7 +20,7 @@ public class StarterAssetsInputs : MonoBehaviour public bool cursorLocked = true; public bool cursorInputForLook = true; -#if ENABLE_INPUT_SYSTEM && STARTER_ASSETS_PACKAGES_CHECKED +#if ENABLE_INPUT_SYSTEM public void OnMove(InputValue value) { MoveInput(value.Get()); @@ -28,7 +28,7 @@ public void OnMove(InputValue value) public void OnLook(InputValue value) { - if(cursorInputForLook) + if (cursorInputForLook) { LookInput(value.Get()); } @@ -49,7 +49,7 @@ public void OnSprint(InputValue value) public void MoveInput(Vector2 newMoveDirection) { move = newMoveDirection; - } + } public void LookInput(Vector2 newLookDirection) { @@ -76,5 +76,5 @@ private void SetCursorState(bool newState) Cursor.lockState = newState ? CursorLockMode.Locked : CursorLockMode.None; } } - + } \ No newline at end of file diff --git a/DarkFlow/Assets/Scripts/InputSystem/StarterAssets_Networked.inputactions b/DarkFlow/Assets/Scripts/InputSystem/StarterAssets_Networked.inputactions new file mode 100644 index 0000000..4c8310f --- /dev/null +++ b/DarkFlow/Assets/Scripts/InputSystem/StarterAssets_Networked.inputactions @@ -0,0 +1,294 @@ +{ + "name": "StarterAssets_Networked", + "maps": [ + { + "name": "Player", + "id": "f62a4b92-ef5e-4175-8f4c-c9075429d32c", + "actions": [ + { + "name": "Move", + "type": "Value", + "id": "6bc1aaf4-b110-4ff7-891e-5b9fe6f32c4d", + "expectedControlType": "Vector2", + "processors": "", + "interactions": "", + "initialStateCheck": true + }, + { + "name": "Look", + "type": "Value", + "id": "2690c379-f54d-45be-a724-414123833eb4", + "expectedControlType": "Vector2", + "processors": "", + "interactions": "", + "initialStateCheck": true + }, + { + "name": "Jump", + "type": "Button", + "id": "8c4abdf8-4099-493a-aa1a-129acec7c3df", + "expectedControlType": "Button", + "processors": "", + "interactions": "", + "initialStateCheck": false + }, + { + "name": "Sprint", + "type": "PassThrough", + "id": "980e881e-182c-404c-8cbf-3d09fdb48fef", + "expectedControlType": "", + "processors": "", + "interactions": "", + "initialStateCheck": false + }, + { + "name": "PickUp", + "type": "Button", + "id": "e7da474d-92b6-41e6-bc91-90d37cd5c73d", + "expectedControlType": "Button", + "processors": "", + "interactions": "", + "initialStateCheck": false + } + ], + "bindings": [ + { + "name": "WASD", + "id": "b7594ddb-26c9-4ba2-bd5a-901468929edc", + "path": "2DVector(mode=1)", + "interactions": "", + "processors": "", + "groups": "", + "action": "Move", + "isComposite": true, + "isPartOfComposite": false + }, + { + "name": "up", + "id": "2063a8b5-6a45-43de-851b-65f3d46e7b58", + "path": "/w", + "interactions": "", + "processors": "", + "groups": "KeyboardMouse", + "action": "Move", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "down", + "id": "64e4d037-32e1-4fb9-80e4-fc7330404dfe", + "path": "/s", + "interactions": "", + "processors": "", + "groups": "KeyboardMouse", + "action": "Move", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "left", + "id": "0fce8b11-5eab-4e4e-a741-b732e7b20873", + "path": "/a", + "interactions": "", + "processors": "", + "groups": "KeyboardMouse", + "action": "Move", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "right", + "id": "7bdda0d6-57a8-47c8-8238-8aecf3110e47", + "path": "/d", + "interactions": "", + "processors": "", + "groups": "KeyboardMouse", + "action": "Move", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "up", + "id": "bb94b405-58d3-4998-8535-d705c1218a98", + "path": "/upArrow", + "interactions": "", + "processors": "", + "groups": "KeyboardMouse", + "action": "Move", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "down", + "id": "929d9071-7dd0-4368-9743-6793bb98087e", + "path": "/downArrow", + "interactions": "", + "processors": "", + "groups": "KeyboardMouse", + "action": "Move", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "left", + "id": "28abadba-06ff-4d37-bb70-af2f1e35a3b9", + "path": "/leftArrow", + "interactions": "", + "processors": "", + "groups": "KeyboardMouse", + "action": "Move", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "right", + "id": "45f115b6-9b4f-4ba8-b500-b94c93bf7d7e", + "path": "/rightArrow", + "interactions": "", + "processors": "", + "groups": "KeyboardMouse", + "action": "Move", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "", + "id": "e2f9aa65-db06-4c5b-a2e9-41bc8acb9517", + "path": "/leftStick", + "interactions": "", + "processors": "StickDeadzone", + "groups": "Gamepad", + "action": "Move", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "ed66cbff-2900-4a62-8896-696503cfcd31", + "path": "/delta", + "interactions": "", + "processors": "InvertVector2(invertX=false),ScaleVector2(x=0.05,y=0.05)", + "groups": "KeyboardMouse", + "action": "Look", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "d1d171b6-19d8-47a6-ba3a-71b6a8e7b3c0", + "path": "/rightStick", + "interactions": "", + "processors": "InvertVector2(invertX=false),StickDeadzone,ScaleVector2(x=300,y=300)", + "groups": "Gamepad", + "action": "Look", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "1bd55a0b-761e-4ae4-89ae-8ec127e08a29", + "path": "/space", + "interactions": "", + "processors": "", + "groups": "KeyboardMouse", + "action": "Jump", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "9f973413-5e27-4239-acee-38c4a63feeba", + "path": "/buttonSouth", + "interactions": "", + "processors": "", + "groups": "Gamepad", + "action": "Jump", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "dc65b89f-9bd3-43fb-92af-d0d87ba5faa4", + "path": "/leftShift", + "interactions": "", + "processors": "", + "groups": "KeyboardMouse", + "action": "Sprint", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "c8fcd86e-dcfd-4f88-8e93-b638cdbf3320", + "path": "/leftTrigger", + "interactions": "", + "processors": "", + "groups": "Gamepad", + "action": "Sprint", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "04c89c8b-fa71-46ba-92ff-e6b8e5ecff92", + "path": "/e", + "interactions": "", + "processors": "", + "groups": "", + "action": "PickUp", + "isComposite": false, + "isPartOfComposite": false + } + ] + } + ], + "controlSchemes": [ + { + "name": "KeyboardMouse", + "bindingGroup": "KeyboardMouse", + "devices": [ + { + "devicePath": "", + "isOptional": false, + "isOR": false + }, + { + "devicePath": "", + "isOptional": false, + "isOR": false + } + ] + }, + { + "name": "Gamepad", + "bindingGroup": "Gamepad", + "devices": [ + { + "devicePath": "", + "isOptional": true, + "isOR": false + }, + { + "devicePath": "", + "isOptional": true, + "isOR": false + }, + { + "devicePath": "", + "isOptional": true, + "isOR": false + } + ] + }, + { + "name": "Xbox Controller", + "bindingGroup": "Xbox Controller", + "devices": [] + }, + { + "name": "PS4 Controller", + "bindingGroup": "PS4 Controller", + "devices": [] + } + ] +} \ No newline at end of file diff --git a/DarkFlow/Assets/Scripts/InputSystem/StarterAssets_Networked.inputactions.meta b/DarkFlow/Assets/Scripts/InputSystem/StarterAssets_Networked.inputactions.meta new file mode 100644 index 0000000..b48370d --- /dev/null +++ b/DarkFlow/Assets/Scripts/InputSystem/StarterAssets_Networked.inputactions.meta @@ -0,0 +1,14 @@ +fileFormatVersion: 2 +guid: 42bbd845906c9dd4fa77e979ee644342 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3} + generateWrapperCode: 0 + wrapperCodePath: + wrapperClassName: + wrapperCodeNamespace: diff --git a/DarkFlow/Assets/Scripts/ServerPlayerMove.cs b/DarkFlow/Assets/Scripts/ServerPlayerMove.cs index aab89f4..3b95a20 100644 --- a/DarkFlow/Assets/Scripts/ServerPlayerMove.cs +++ b/DarkFlow/Assets/Scripts/ServerPlayerMove.cs @@ -7,25 +7,13 @@ [DefaultExecutionOrder(0)] // before client component public class ServerPlayerMove : NetworkBehaviour { - public NetworkVariable isObjectPickedUp = new NetworkVariable(); - - NetworkObject m_PickedUpObject; - - [SerializeField] - Vector3 m_LocalHeldPosition; - public override void OnNetworkSpawn() { - if (!IsServer) - { - enabled = false; - return; - } - - OnServerSpawnPlayer(); - - base.OnNetworkSpawn(); + if (!IsServer) { return; } + + //OnServerSpawnPlayer(); + } void OnServerSpawnPlayer() @@ -33,8 +21,9 @@ void OnServerSpawnPlayer() // this is done server side, so we have a single source of truth for our spawn point list var spawnPoint = ServerPlayerSpawnPoints.Instance.ConsumeNextSpawnPoint(); var spawnPosition = spawnPoint ? spawnPoint.transform.position : Vector3.zero; - transform.position = spawnPosition; - + this.transform.position = spawnPosition; + //Debug.Log(".......... Server"); + // A note specific to owner authority: // Side Note: Specific to Owner Authoritative // Setting the position works as and can be set in OnNetworkSpawn server-side unless there is a @@ -45,11 +34,4 @@ void OnServerSpawnPlayer() // transform after synchronization with the initial position, thus overwriting the synchronized position. } - - - - - - - } diff --git a/DarkFlow/Packages/manifest.json b/DarkFlow/Packages/manifest.json index 5059c17..ad73829 100644 --- a/DarkFlow/Packages/manifest.json +++ b/DarkFlow/Packages/manifest.json @@ -4,6 +4,7 @@ "com.unity.ide.visualstudio": "2.0.22", "com.unity.ide.vscode": "1.2.5", "com.unity.inputsystem": "1.7.0", + "com.unity.multiplayer.tools": "2.0.0-pre.5", "com.unity.netcode.gameobjects": "1.7.1", "com.unity.render-pipelines.universal": "14.0.9", "com.unity.services.lobby": "1.1.2", @@ -11,7 +12,7 @@ "com.unity.services.multiplay": "1.1.1", "com.unity.services.relay": "1.0.5", "com.unity.textmeshpro": "3.0.6", - "com.unity.toolchain.win-x86_64-linux-x86_64": "2.0.4", + "com.unity.toolchain.win-x86_64-linux-x86_64": "2.0.6", "com.unity.ugui": "1.0.0", "com.unity.visualscripting": "1.9.1", "com.veriorpies.parrelsync": "https://github.com/VeriorPies/ParrelSync.git?path=/ParrelSync", diff --git a/DarkFlow/Packages/packages-lock.json b/DarkFlow/Packages/packages-lock.json index 3f71283..b5f2fdf 100644 --- a/DarkFlow/Packages/packages-lock.json +++ b/DarkFlow/Packages/packages-lock.json @@ -20,7 +20,7 @@ }, "com.unity.collections": { "version": "1.2.4", - "depth": 2, + "depth": 1, "source": "registry", "dependencies": { "com.unity.burst": "1.6.6", @@ -67,6 +67,21 @@ "dependencies": {}, "url": "https://packages.unity.com" }, + "com.unity.multiplayer.tools": { + "version": "2.0.0-pre.5", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.profiling.core": "1.0.0-pre.1", + "com.unity.nuget.newtonsoft-json": "2.0.0", + "com.unity.nuget.mono-cecil": "1.10.1", + "com.unity.collections": "1.1.0", + "com.unity.modules.uielements": "1.0.0", + "com.unity.burst": "1.6.6", + "com.unity.mathematics": "1.2.6" + }, + "url": "https://packages.unity.com" + }, "com.unity.netcode.gameobjects": { "version": "1.7.1", "depth": 0, @@ -91,6 +106,13 @@ "dependencies": {}, "url": "https://packages.unity.com" }, + "com.unity.profiling.core": { + "version": "1.0.2", + "depth": 1, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, "com.unity.render-pipelines.core": { "version": "14.0.9", "depth": 1, @@ -253,18 +275,18 @@ } }, "com.unity.sysroot": { - "version": "2.0.5", + "version": "2.0.7", "depth": 1, "source": "registry", "dependencies": {}, "url": "https://packages.unity.com" }, "com.unity.sysroot.linux-x86_64": { - "version": "2.0.4", + "version": "2.0.6", "depth": 1, "source": "registry", "dependencies": { - "com.unity.sysroot": "2.0.5" + "com.unity.sysroot": "2.0.7" }, "url": "https://packages.unity.com" }, @@ -289,12 +311,12 @@ "url": "https://packages.unity.com" }, "com.unity.toolchain.win-x86_64-linux-x86_64": { - "version": "2.0.4", + "version": "2.0.6", "depth": 0, "source": "registry", "dependencies": { - "com.unity.sysroot": "2.0.5", - "com.unity.sysroot.linux-x86_64": "2.0.4" + "com.unity.sysroot": "2.0.7", + "com.unity.sysroot.linux-x86_64": "2.0.6" }, "url": "https://packages.unity.com" }, diff --git a/DarkFlow/ProjectSettings/ProjectSettings.asset b/DarkFlow/ProjectSettings/ProjectSettings.asset index fda5f2b..24c524c 100644 --- a/DarkFlow/ProjectSettings/ProjectSettings.asset +++ b/DarkFlow/ProjectSettings/ProjectSettings.asset @@ -797,7 +797,23 @@ PlayerSettings: webGLMemoryGeometricGrowthCap: 96 webGLPowerPreference: 2 scriptingDefineSymbols: - Standalone: CROSS_PLATFORM_INPUT + Android: UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE;UNITY_MP_TOOLS_NETSIM_ENABLED_IN_RELEASE + EmbeddedLinux: UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE;UNITY_MP_TOOLS_NETSIM_ENABLED_IN_RELEASE + GameCoreScarlett: UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE;UNITY_MP_TOOLS_NETSIM_ENABLED_IN_RELEASE + GameCoreXboxOne: UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE;UNITY_MP_TOOLS_NETSIM_ENABLED_IN_RELEASE + LinuxHeadlessSimulation: UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE;UNITY_MP_TOOLS_NETSIM_ENABLED_IN_RELEASE + Nintendo Switch: UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE;UNITY_MP_TOOLS_NETSIM_ENABLED_IN_RELEASE + PS4: UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE;UNITY_MP_TOOLS_NETSIM_ENABLED_IN_RELEASE + PS5: UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE;UNITY_MP_TOOLS_NETSIM_ENABLED_IN_RELEASE + QNX: UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE;UNITY_MP_TOOLS_NETSIM_ENABLED_IN_RELEASE + Stadia: UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE;UNITY_MP_TOOLS_NETSIM_ENABLED_IN_RELEASE + Standalone: CROSS_PLATFORM_INPUT;UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE;UNITY_MP_TOOLS_NETSIM_ENABLED_IN_RELEASE + VisionOS: UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE;UNITY_MP_TOOLS_NETSIM_ENABLED_IN_RELEASE + WebGL: UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE;UNITY_MP_TOOLS_NETSIM_ENABLED_IN_RELEASE + Windows Store Apps: UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE;UNITY_MP_TOOLS_NETSIM_ENABLED_IN_RELEASE + XboxOne: UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE;UNITY_MP_TOOLS_NETSIM_ENABLED_IN_RELEASE + iPhone: UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE;UNITY_MP_TOOLS_NETSIM_ENABLED_IN_RELEASE + tvOS: UNITY_MP_TOOLS_NET_STATS_MONITOR_ENABLED_IN_RELEASE;UNITY_MP_TOOLS_NETSIM_ENABLED_IN_RELEASE additionalCompilerArguments: {} platformArchitecture: {} scriptingBackend: {}