From c62d7e5c072d489a79312294fe531af69b6b90b2 Mon Sep 17 00:00:00 2001 From: JesusLuvsYooh <57072365+JesusLuvsYooh@users.noreply.github.com> Date: Tue, 14 May 2024 12:10:28 +0100 Subject: [PATCH] Fancy camera for couch coop example, and player list. (#3821) --- .../Examples/CouchCoop/MirrorCouchCoop.unity | 307 ++++++++++++++---- .../CouchCoop/Scripts/CameraViewForAll.cs | 73 +++++ .../Scripts/CameraViewForAll.cs.meta | 11 + .../Examples/CouchCoop/Scripts/CouchPlayer.cs | 25 +- 4 files changed, 342 insertions(+), 74 deletions(-) create mode 100644 Assets/Mirror/Examples/CouchCoop/Scripts/CameraViewForAll.cs create mode 100644 Assets/Mirror/Examples/CouchCoop/Scripts/CameraViewForAll.cs.meta diff --git a/Assets/Mirror/Examples/CouchCoop/MirrorCouchCoop.unity b/Assets/Mirror/Examples/CouchCoop/MirrorCouchCoop.unity index d4847f360..1abbb2ff2 100644 --- a/Assets/Mirror/Examples/CouchCoop/MirrorCouchCoop.unity +++ b/Assets/Mirror/Examples/CouchCoop/MirrorCouchCoop.unity @@ -105,7 +105,7 @@ NavMeshSettings: serializedVersion: 2 m_ObjectHideFlags: 0 m_BuildSettings: - serializedVersion: 2 + serializedVersion: 3 agentTypeID: 0 agentRadius: 0.5 agentHeight: 2 @@ -118,7 +118,7 @@ NavMeshSettings: cellSize: 0.16666667 manualTileSize: 0 tileSize: 256 - accuratePlacement: 0 + buildHeightMesh: 0 maxJobWorkers: 0 preserveTilesOutsideBounds: 0 debug: @@ -150,13 +150,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 34377703} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 4, z: 10} m_LocalScale: {x: 40, y: 10, z: 0.01} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 335647024} - m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!65 &34377705 BoxCollider: @@ -166,9 +166,17 @@ BoxCollider: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 34377703} 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 + serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} --- !u!23 &34377706 @@ -247,13 +255,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 80415366} + serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 7.49, y: 1.5, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1284305745} - m_RootOrder: 7 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!65 &80415368 BoxCollider: @@ -263,9 +271,17 @@ BoxCollider: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 80415366} 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 + serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} --- !u!23 &80415369 @@ -329,6 +345,7 @@ GameObject: - component: {fileID: 88936777} - component: {fileID: 88936776} - component: {fileID: 88936778} + - component: {fileID: 88936779} m_Layer: 0 m_Name: Main Camera m_TagString: MainCamera @@ -350,9 +367,17 @@ Camera: m_projectionMatrixMode: 1 m_GateFitMode: 2 m_FOVAxisMode: 0 + m_Iso: 200 + m_ShutterSpeed: 0.005 + m_Aperture: 16 + m_FocusDistance: 10 + m_FocalLength: 50 + m_BladeCount: 5 + m_Curvature: {x: 2, y: 11} + m_BarrelClipping: 0.25 + m_Anamorphism: 0 m_SensorSize: {x: 36, y: 24} m_LensShift: {x: 0, y: 0} - m_FocalLength: 50 m_NormalizedViewPortRect: serializedVersion: 2 x: 0 @@ -362,8 +387,8 @@ Camera: near clip plane: 0.3 far clip plane: 1000 field of view: 60 - orthographic: 0 - orthographic size: 5 + orthographic: 1 + orthographic size: 7 m_Depth: -1 m_CullingMask: serializedVersion: 2 @@ -386,13 +411,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 88936773} + serializedVersion: 2 m_LocalRotation: {x: 0.2164396, y: 0, z: 0, w: 0.97629607} m_LocalPosition: {x: 0, y: 6.7, z: -10.4} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 25, y: 0, z: 0} --- !u!114 &88936778 MonoBehaviour: @@ -407,8 +432,31 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: height: 150 + offsetY: 40 maxLogCount: 50 + showInEditor: 0 hotKey: 293 +--- !u!114 &88936779 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 88936773} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 73edff93783204b298f805477ae30ecd, type: 3} + m_Name: + m_EditorClassIdentifier: + cameraTransform: {fileID: 88936777} + camSpeed: 2 + orthoSizeSpeed: 2 + mainCamera: {fileID: 88936776} + cameraZ: -5 + cameraBufferX: 0.1 + cameraBufferY: 0.1 + minOrthographicSize: 0.1 + targetYPosition: 4.5 --- !u!1 &121552833 GameObject: m_ObjectHideFlags: 0 @@ -435,13 +483,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 121552833} + serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 5.972, y: 2.5, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1284305745} - m_RootOrder: 6 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!65 &121552835 BoxCollider: @@ -451,9 +499,17 @@ BoxCollider: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 121552833} 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 + serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} --- !u!23 &121552836 @@ -529,6 +585,7 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 335647023} + 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} @@ -541,7 +598,6 @@ Transform: - {fileID: 498523323} - {fileID: 1263590060} m_Father: {fileID: 0} - m_RootOrder: 6 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &388677686 GameObject: @@ -570,9 +626,17 @@ BoxCollider: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 388677686} 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 + serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} --- !u!23 &388677688 @@ -632,13 +696,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 388677686} + serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 20, y: 2, z: 5} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1284305745} - m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &437386904 GameObject: @@ -664,13 +728,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 437386904} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 5, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 4239341309712137294} - m_RootOrder: 9 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &437386906 MonoBehaviour: @@ -710,13 +774,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 446496352} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 4, z: -10} m_LocalScale: {x: 40, y: 10, z: 0.01} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 335647024} - m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!65 &446496354 BoxCollider: @@ -726,9 +790,17 @@ BoxCollider: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 446496352} 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 + serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} --- !u!23 &446496355 @@ -807,13 +879,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 450288645} + serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: -5.58, y: 3.41, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1284305745} - m_RootOrder: 10 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!65 &450288647 BoxCollider: @@ -823,9 +895,17 @@ BoxCollider: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 450288645} 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 + serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} --- !u!23 &450288648 @@ -904,13 +984,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 460980894} + serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: -3.55, y: 1.5, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1284305745} - m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!65 &460980896 BoxCollider: @@ -920,9 +1000,17 @@ BoxCollider: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 460980894} 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 + serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} --- !u!23 &460980897 @@ -999,13 +1087,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 472126870} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: -2, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 4239341309712137294} - m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &472126872 MonoBehaviour: @@ -1045,13 +1133,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 498523322} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0.7071068, z: 0, w: 0.7071068} m_LocalPosition: {x: -20, y: 4, z: 0} m_LocalScale: {x: 20, y: 10, z: 0.01} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 335647024} - m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0} --- !u!65 &498523324 BoxCollider: @@ -1061,9 +1149,17 @@ BoxCollider: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 498523322} 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 + serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} --- !u!23 &498523325 @@ -1140,13 +1236,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 605740505} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: -1, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 4239341309712137294} - m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &605740507 MonoBehaviour: @@ -1193,7 +1289,6 @@ RectTransform: m_Children: - {fileID: 1420928155} m_Father: {fileID: 1324361701} - m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0.5} m_AnchorMax: {x: 0, y: 0.5} @@ -1308,13 +1403,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 738449925} + serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 5.38, y: 1.5, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1284305745} - m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!65 &738449927 BoxCollider: @@ -1324,9 +1419,17 @@ BoxCollider: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 738449925} 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 + serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} --- !u!23 &738449928 @@ -1403,13 +1506,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 778458459} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: -6, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 4239341309712137294} - m_RootOrder: 11 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &778458461 MonoBehaviour: @@ -1449,13 +1552,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 828682885} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 22.4} m_LocalScale: {x: 100, y: 0.01, z: 100} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 335647024} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!65 &828682887 BoxCollider: @@ -1465,9 +1568,17 @@ BoxCollider: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 828682885} 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 + serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} --- !u!23 &828682888 @@ -1546,13 +1657,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 881756481} + serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: -6.605, y: 3.804, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1284305745} - m_RootOrder: 9 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!65 &881756483 BoxCollider: @@ -1562,9 +1673,17 @@ BoxCollider: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 881756481} 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 + serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} --- !u!23 &881756484 @@ -1643,13 +1762,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 898358220} + serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 6.42, y: 1.5, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1284305745} - m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!65 &898358222 BoxCollider: @@ -1659,9 +1778,17 @@ BoxCollider: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 898358220} 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 + serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} --- !u!23 &898358223 @@ -1789,13 +1916,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1107091652} + serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 21.8} m_LocalScale: {x: 10, y: 1, z: 10} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1284305745} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1111626353 GameObject: @@ -1828,7 +1955,6 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1324361701} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0.5} m_AnchorMax: {x: 0, y: 0.5} @@ -1908,13 +2034,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1179387011} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0.7071068, z: 0, w: 0.7071068} m_LocalPosition: {x: 20, y: 4, z: 0} m_LocalScale: {x: 20, y: 10, z: 0.01} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 335647024} - m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0} --- !u!65 &1179387013 BoxCollider: @@ -1924,9 +2050,17 @@ BoxCollider: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1179387011} 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 + serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} --- !u!23 &1179387014 @@ -2005,13 +2139,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1263590059} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 9, z: 0} m_LocalScale: {x: 40, y: 0.01, z: 20} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 335647024} - m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!65 &1263590061 BoxCollider: @@ -2021,9 +2155,17 @@ BoxCollider: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1263590059} 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 + serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} --- !u!23 &1263590062 @@ -2099,6 +2241,7 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1284305744} + 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} @@ -2116,7 +2259,6 @@ Transform: - {fileID: 881756482} - {fileID: 450288646} m_Father: {fileID: 0} - m_RootOrder: 7 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1305041271 GameObject: @@ -2142,13 +2284,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1305041271} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: -3, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 4239341309712137294} - m_RootOrder: 6 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &1305041273 MonoBehaviour: @@ -2196,7 +2338,6 @@ RectTransform: - {fileID: 1844416208} - {fileID: 655358420} m_Father: {fileID: 1691128381} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -2265,13 +2406,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1372141312} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 6, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 4239341309712137294} - m_RootOrder: 10 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &1372141314 MonoBehaviour: @@ -2316,7 +2457,6 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 655358420} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} @@ -2389,13 +2529,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1562669729} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: -5, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 4239341309712137294} - m_RootOrder: 8 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &1562669731 MonoBehaviour: @@ -2435,13 +2575,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1648326108} + serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 4.3, y: 1.5, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1284305745} - m_RootOrder: 8 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!65 &1648326110 BoxCollider: @@ -2451,9 +2591,17 @@ BoxCollider: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1648326108} 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 + serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} --- !u!23 &1648326111 @@ -2583,7 +2731,9 @@ Canvas: m_OverrideSorting: 0 m_OverridePixelPerfect: 0 m_SortingBucketNormalizedSize: 0 + m_VertexColorAlwaysGammaSpace: 0 m_AdditionalShaderChannelsFlag: 0 + m_UpdateRectTransformForStandalone: 0 m_SortingLayerID: 0 m_SortingOrder: 0 m_TargetDisplay: 0 @@ -2601,7 +2751,6 @@ RectTransform: m_Children: - {fileID: 1324361701} m_Father: {fileID: 0} - m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -2649,13 +2798,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1766357185} + serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: -2.5, y: 1.5, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1284305745} - m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!65 &1766357187 BoxCollider: @@ -2665,9 +2814,17 @@ BoxCollider: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1766357185} 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 + serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} --- !u!23 &1766357188 @@ -2753,7 +2910,6 @@ RectTransform: m_Children: - {fileID: 1922846804} m_Father: {fileID: 1324361701} - m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0.5} m_AnchorMax: {x: 0, y: 0.5} @@ -2873,7 +3029,6 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1844416208} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} @@ -3008,13 +3163,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2054208274} + serializedVersion: 2 m_LocalRotation: {x: 0.39044833, y: -0.34682897, z: 0.161729, w: 0.8373192} m_LocalPosition: {x: 0, y: 10, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 50, y: -45, z: 0} --- !u!1 &2103688474 GameObject: @@ -3040,13 +3195,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2103688474} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: -4, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 4239341309712137294} - m_RootOrder: 7 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &2103688476 MonoBehaviour: @@ -3086,13 +3241,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2816348668128435081} + 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: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &2816348668128435084 MonoBehaviour: @@ -3133,7 +3288,7 @@ MonoBehaviour: MaxRetransmit: 40 MaximizeSocketBuffers: 1 ReliableMaxMessageSize: 297433 - UnreliableMaxMessageSize: 1195 + UnreliableMaxMessageSize: 1194 debugLog: 0 statisticsGUI: 0 statisticsLog: 0 @@ -3151,9 +3306,11 @@ MonoBehaviour: m_EditorClassIdentifier: dontDestroyOnLoad: 1 runInBackground: 1 - autoStartServerBuild: 1 - autoConnectClientBuild: 0 + headlessStartMode: 1 + editorAutoStart: 0 sendRate: 60 + autoStartServerBuild: 0 + autoConnectClientBuild: 0 offlineScene: onlineScene: transport: {fileID: 2816348668128435085} @@ -3168,6 +3325,7 @@ MonoBehaviour: playerSpawnMethod: 1 spawnPrefabs: - {fileID: 8872462076811691049, guid: c5eb745ce31f9439f9bb3fe7c091ad27, type: 3} + exceptionsDisconnect: 1 snapshotSettings: bufferTimeMultiplier: 2 bufferLimit: 32 @@ -3179,7 +3337,8 @@ MonoBehaviour: dynamicAdjustment: 1 dynamicAdjustmentTolerance: 1 deliveryTimeEmaDuration: 2 - connectionQualityInterval: 3 + evaluationMethod: 0 + evaluationInterval: 3 timeInterpolationGui: 0 --- !u!1 &4239341308390436545 GameObject: @@ -3205,13 +3364,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 4239341308390436545} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 4, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 4239341309712137294} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &4239341308390436547 MonoBehaviour: @@ -3249,13 +3408,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 4239341308987619385} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 1, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 4239341309712137294} - m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &4239341308987619387 MonoBehaviour: @@ -3293,13 +3452,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 4239341309125333740} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 2, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 4239341309712137294} - m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &4239341309125333742 MonoBehaviour: @@ -3336,6 +3495,7 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 4239341309712137293} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 6, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} @@ -3354,7 +3514,6 @@ Transform: - {fileID: 1372141313} - {fileID: 778458460} m_Father: {fileID: 0} - m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &4239341310108531883 GameObject: @@ -3380,13 +3539,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 4239341310108531883} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 3, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 4239341309712137294} - m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &4239341310108531885 MonoBehaviour: @@ -3407,13 +3566,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 5746453777584925836} + 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: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &5746453777584925834 MonoBehaviour: @@ -3468,3 +3627,15 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 +--- !u!1660057539 &9223372036854775807 +SceneRoots: + m_ObjectHideFlags: 0 + m_Roots: + - {fileID: 88936777} + - {fileID: 2054208276} + - {fileID: 4239341309712137294} + - {fileID: 2816348668128435083} + - {fileID: 5746453777584925833} + - {fileID: 1691128381} + - {fileID: 335647024} + - {fileID: 1284305745} diff --git a/Assets/Mirror/Examples/CouchCoop/Scripts/CameraViewForAll.cs b/Assets/Mirror/Examples/CouchCoop/Scripts/CameraViewForAll.cs new file mode 100644 index 000000000..5e2579cc1 --- /dev/null +++ b/Assets/Mirror/Examples/CouchCoop/Scripts/CameraViewForAll.cs @@ -0,0 +1,73 @@ +using UnityEngine; +namespace Mirror.Examples.CouchCoop +{ + public class CameraViewForAll : MonoBehaviour + { + public Transform cameraTransform; + public float camSpeed = 2.0f; + public float orthoSizeSpeed = 2.0f; + public Camera mainCamera; + public float cameraZ = -5; + + public float cameraBufferX = 0.1f; + public float cameraBufferY = 0.1f; + public float minOrthographicSize = 0.1f; + public float targetYPosition = 4.5f; // Optional Y position if cameras rotated + + private Vector2Int boundsMin; + private Vector2Int boundsMax; + private Vector3 targetCameraPosition; + private float targetOrthographicSize; + + private void Update() + { + if (CouchPlayer.playersList.Count > 0) + { + CalculateBounds(); + CalculateTargetCameraPosAndSize(); + MoveCamera(); + } + } + + private void CalculateBounds() + { + boundsMin = new Vector2Int(int.MaxValue, int.MaxValue); + boundsMax = new Vector2Int(int.MinValue, int.MinValue); + + foreach (GameObject player in CouchPlayer.playersList) + { + Vector3 playerPosition = player.transform.position; + boundsMin.x = Mathf.Min(boundsMin.x, Mathf.FloorToInt(playerPosition.x)); + boundsMin.y = Mathf.Min(boundsMin.y, Mathf.FloorToInt(playerPosition.y)); + boundsMax.x = Mathf.Max(boundsMax.x, Mathf.CeilToInt(playerPosition.x)); + boundsMax.y = Mathf.Max(boundsMax.y, Mathf.CeilToInt(playerPosition.y)); + } + + boundsMin.x -= Mathf.FloorToInt(cameraBufferX); + boundsMin.y -= Mathf.FloorToInt(cameraBufferY); + boundsMax.x += Mathf.CeilToInt(cameraBufferX); + boundsMax.y += Mathf.CeilToInt(cameraBufferY); + } + + private void CalculateTargetCameraPosAndSize() + { + float aspectRatio = (float)Screen.width / Screen.height; + + float requiredOrthographicSizeX = Mathf.Max((boundsMax.x - boundsMin.x) / 2 / aspectRatio, minOrthographicSize / aspectRatio); + float requiredOrthographicSizeY = Mathf.Max(boundsMax.y - boundsMin.y / 2, minOrthographicSize); + + targetOrthographicSize = Mathf.Max(requiredOrthographicSizeX, requiredOrthographicSizeY); + + float cameraX = (boundsMax.x + boundsMin.x) / 2; + float cameraY = targetYPosition != 0.0f ? targetYPosition : (boundsMax.y + boundsMin.y) / 2; + + targetCameraPosition = new Vector3(cameraX, cameraY, cameraZ); + } + + private void MoveCamera() + { + cameraTransform.position = Vector3.Lerp(cameraTransform.position, targetCameraPosition, camSpeed * Time.deltaTime); + mainCamera.orthographicSize = Mathf.Lerp(mainCamera.orthographicSize, targetOrthographicSize, orthoSizeSpeed * Time.deltaTime); + } + } +} \ No newline at end of file diff --git a/Assets/Mirror/Examples/CouchCoop/Scripts/CameraViewForAll.cs.meta b/Assets/Mirror/Examples/CouchCoop/Scripts/CameraViewForAll.cs.meta new file mode 100644 index 000000000..103e535b6 --- /dev/null +++ b/Assets/Mirror/Examples/CouchCoop/Scripts/CameraViewForAll.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 73edff93783204b298f805477ae30ecd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Mirror/Examples/CouchCoop/Scripts/CouchPlayer.cs b/Assets/Mirror/Examples/CouchCoop/Scripts/CouchPlayer.cs index f50a8f1cf..eee9eca85 100644 --- a/Assets/Mirror/Examples/CouchCoop/Scripts/CouchPlayer.cs +++ b/Assets/Mirror/Examples/CouchCoop/Scripts/CouchPlayer.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; @@ -20,6 +21,23 @@ public class CouchPlayer : NetworkBehaviour public int playerNumber = 0; public Text textPlayerNumber; + // a list of players, is used for camera + public readonly static List playersList = new List(); + + public void Start() + { + playersList.Add(this.gameObject); + // print("playersList: " + playersList.Count); + + SetPlayerUI(); + } + + public void OnDestroy() + { + playersList.Remove(this.gameObject); + // print("playersList: " + playersList.Count); + } + public override void OnStartAuthority() { this.enabled = true; @@ -39,11 +57,6 @@ public override void OnStartAuthority() } } - public void Start() - { - SetPlayerUI(); - } - void Update() { if (!Application.isFocused) return; @@ -86,7 +99,7 @@ void OnCollisionStay(Collision col) if (isOwned == false) { return; } isGrounded = true; } - + void OnNumberChangedHook(int _old, int _new) { //Debug.Log(name + " - OnNumberChangedHook: " + playerNumber);