From 0b6a8440fcd428c8dbf10e7bdc24649dba908338 Mon Sep 17 00:00:00 2001 From: Jamie Greunbaum Date: Sat, 21 Mar 2026 01:02:39 -0400 Subject: [PATCH] - Camera follower will now track the upper-midsections of VRChat players. - Camera tracking now has a follow speed setting. - Camera anchor FOV scaler is now a separate object. - Camera overlays now overlay properly once again. - Implemented a much better check for whether a camera was detached. - Improved code that detects when a game is over, and why it ended. - Tweaked ending camera animation timing. --- .../Round 3 Cameras/Do It Rockapella.anim | 46 +-- .../Camera/Round 3 Cameras/I Feel Good.anim | 66 ++++- Assets/Prefabs/Camera Anchor.prefab | 35 ++- Assets/Scenes/witwics.unity | 45 ++- Assets/UdonSharp/Cameras/CameraAnchor.asset | 268 ++++++++++++------ Assets/UdonSharp/Cameras/CameraAnchor.cs | 61 ++-- .../Cameras/CameraControllerRound3.cs | 8 +- .../Game Managers/GameManagerRound3.cs | 60 +++- 8 files changed, 423 insertions(+), 166 deletions(-) diff --git a/Assets/Animations/Camera/Round 3 Cameras/Do It Rockapella.anim b/Assets/Animations/Camera/Round 3 Cameras/Do It Rockapella.anim index af4bf98..c9d4ca5 100644 --- a/Assets/Animations/Camera/Round 3 Cameras/Do It Rockapella.anim +++ b/Assets/Animations/Camera/Round 3 Cameras/Do It Rockapella.anim @@ -19,7 +19,7 @@ AnimationClip: m_Curve: - serializedVersion: 3 time: 0 - value: {x: 28.591, y: -90, z: 0} + value: {x: 43.82, y: -90, z: 0} inSlope: {x: 0, y: 0, z: 0} outSlope: {x: 0, y: 0, z: 0} tangentMode: 0 @@ -71,26 +71,26 @@ AnimationClip: m_Curve: - serializedVersion: 3 time: 0 - value: {x: 1, y: 1, z: 0.22346} - inSlope: {x: 0, y: 0, z: 0} - outSlope: {x: 0, y: 0, z: 0} + value: {x: 1, y: 1, z: 0.4} + inSlope: {x: 0, y: 0, z: 0.847138} + outSlope: {x: 0, y: 0, z: 0.847138} tangentMode: 0 weightedMode: 0 inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} - outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} + outWeight: {x: 0.33333334, y: 0.33333334, z: 0.04411765} - serializedVersion: 3 time: 2 value: {x: 1, y: 1, z: 1} - inSlope: {x: 0, y: 0, z: 0} - outSlope: {x: 0, y: 0, z: 0} + inSlope: {x: 0, y: 0, z: 0.062066503} + outSlope: {x: 0, y: 0, z: 0.062066503} tangentMode: 0 weightedMode: 0 - inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} + inWeight: {x: 0.33333334, y: 0.33333334, z: 0.08137256} outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 - path: Overhead Camera Anchor/Camera Root + path: Overhead Camera Anchor/Camera FOV Scaler m_FloatCurves: [] m_PPtrCurves: [] m_SampleRate: 60 @@ -119,7 +119,7 @@ AnimationClip: isIntCurve: 0 isSerializeReferenceCurve: 0 - serializedVersion: 2 - path: 317110899 + path: 1531435860 attribute: 3 script: {fileID: 0} typeID: 4 @@ -245,7 +245,7 @@ AnimationClip: m_Curve: - serializedVersion: 3 time: 0 - value: 28.591 + value: 43.82 inSlope: 0 outSlope: 0 tangentMode: 136 @@ -355,7 +355,7 @@ AnimationClip: m_PostInfinity: 2 m_RotationOrder: 4 attribute: m_LocalScale.x - path: Overhead Camera Anchor/Camera Root + path: Overhead Camera Anchor/Camera FOV Scaler classID: 4 script: {fileID: 0} flags: 0 @@ -385,7 +385,7 @@ AnimationClip: m_PostInfinity: 2 m_RotationOrder: 4 attribute: m_LocalScale.y - path: Overhead Camera Anchor/Camera Root + path: Overhead Camera Anchor/Camera FOV Scaler classID: 4 script: {fileID: 0} flags: 0 @@ -395,27 +395,27 @@ AnimationClip: m_Curve: - serializedVersion: 3 time: 0 - value: 0.22346 - inSlope: 0 - outSlope: 0 - tangentMode: 136 + value: 0.4 + inSlope: 0.847138 + outSlope: 0.847138 + tangentMode: 0 weightedMode: 0 inWeight: 0.33333334 - outWeight: 0.33333334 + outWeight: 0.04411765 - serializedVersion: 3 time: 2 value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 136 + inSlope: 0.062066503 + outSlope: 0.062066503 + tangentMode: 0 weightedMode: 0 - inWeight: 0.33333334 + inWeight: 0.08137256 outWeight: 0.33333334 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 attribute: m_LocalScale.z - path: Overhead Camera Anchor/Camera Root + path: Overhead Camera Anchor/Camera FOV Scaler classID: 4 script: {fileID: 0} flags: 0 diff --git a/Assets/Animations/Camera/Round 3 Cameras/I Feel Good.anim b/Assets/Animations/Camera/Round 3 Cameras/I Feel Good.anim index ac7870e..ecc01da 100644 --- a/Assets/Animations/Camera/Round 3 Cameras/I Feel Good.anim +++ b/Assets/Animations/Camera/Round 3 Cameras/I Feel Good.anim @@ -27,7 +27,7 @@ AnimationClip: inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} - serializedVersion: 3 - time: 0.5 + time: 0.33333334 value: {x: 15.834, y: -90, z: 0} inSlope: {x: 0, y: 0, z: 0} outSlope: {x: -0.0000085965, y: 0, z: 0} @@ -62,7 +62,7 @@ AnimationClip: inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} - serializedVersion: 3 - time: 0.5 + time: 0.33333334 value: {x: -15, y: 0.25, z: 1.04} inSlope: {x: 0, y: 0, z: 0} outSlope: {x: 0, y: 0.11348749, z: 0} @@ -96,10 +96,19 @@ AnimationClip: weightedMode: 0 inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} + - serializedVersion: 3 + time: 4.5 + value: {x: 1, y: 1, z: 1} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 + weightedMode: 0 + inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} + outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 - path: Overhead Camera Anchor/Camera Root + path: Overhead Camera Anchor/Camera FOV Scaler m_FloatCurves: [] m_PPtrCurves: [] m_SampleRate: 60 @@ -128,7 +137,7 @@ AnimationClip: isIntCurve: 0 isSerializeReferenceCurve: 0 - serializedVersion: 2 - path: 317110899 + path: 1531435860 attribute: 3 script: {fileID: 0} typeID: 4 @@ -172,7 +181,7 @@ AnimationClip: inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 - time: 0.5 + time: 0.33333334 value: -15 inSlope: 0 outSlope: 0 @@ -211,7 +220,7 @@ AnimationClip: inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 - time: 0.5 + time: 0.33333334 value: 0.25 inSlope: 0 outSlope: 0.11348749 @@ -250,7 +259,7 @@ AnimationClip: inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 - time: 0.5 + time: 0.33333334 value: 1.04 inSlope: 0 outSlope: 0 @@ -289,7 +298,7 @@ AnimationClip: inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 - time: 0.5 + time: 0.33333334 value: 15.834 inSlope: 0 outSlope: -0.0000085965 @@ -328,7 +337,7 @@ AnimationClip: inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 - time: 0.5 + time: 0.33333334 value: -90 inSlope: 0 outSlope: 0 @@ -367,7 +376,7 @@ AnimationClip: inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 - time: 0.5 + time: 0.33333334 value: 0 inSlope: 0 outSlope: 0 @@ -405,11 +414,20 @@ AnimationClip: weightedMode: 0 inWeight: 0.33333334 outWeight: 0.33333334 + - serializedVersion: 3 + time: 4.5 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 attribute: m_LocalScale.x - path: Overhead Camera Anchor/Camera Root + path: Overhead Camera Anchor/Camera FOV Scaler classID: 4 script: {fileID: 0} flags: 0 @@ -426,11 +444,20 @@ AnimationClip: weightedMode: 0 inWeight: 0.33333334 outWeight: 0.33333334 + - serializedVersion: 3 + time: 4.5 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 attribute: m_LocalScale.y - path: Overhead Camera Anchor/Camera Root + path: Overhead Camera Anchor/Camera FOV Scaler classID: 4 script: {fileID: 0} flags: 0 @@ -447,11 +474,20 @@ AnimationClip: weightedMode: 0 inWeight: 0.33333334 outWeight: 0.33333334 + - serializedVersion: 3 + time: 4.5 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 attribute: m_LocalScale.z - path: Overhead Camera Anchor/Camera Root + path: Overhead Camera Anchor/Camera FOV Scaler classID: 4 script: {fileID: 0} flags: 0 @@ -463,7 +499,7 @@ AnimationClip: m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 - attribute: m_LocalEulerAngles.x + attribute: m_LocalEulerAngles.z path: Overhead Camera Anchor classID: 4 script: {fileID: 0} @@ -487,7 +523,7 @@ AnimationClip: m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 - attribute: m_LocalEulerAngles.z + attribute: m_LocalEulerAngles.x path: Overhead Camera Anchor classID: 4 script: {fileID: 0} diff --git a/Assets/Prefabs/Camera Anchor.prefab b/Assets/Prefabs/Camera Anchor.prefab index 94f4420..490b5d2 100644 --- a/Assets/Prefabs/Camera Anchor.prefab +++ b/Assets/Prefabs/Camera Anchor.prefab @@ -63,6 +63,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: - {fileID: 6802575006468162178} + - {fileID: 4789832517991542133} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &1360612188282181879 @@ -87,11 +88,12 @@ MonoBehaviour: PrefabModifications: [] SerializationNodes: [] _udonSharpBackingUdonBehaviour: {fileID: 4941474114823655580} + CameraSystemManager: {fileID: 0} FOV: 60 NearClippingPlane: 0.3 FarClippingPlane: 1000 CameraRoot: {fileID: 6802575006468162178} - FOVChangeObject: {fileID: 0} + CameraFOVScaler: {fileID: 4789832517991542133} --- !u!114 &4941474114823655580 MonoBehaviour: m_ObjectHideFlags: 0 @@ -118,3 +120,34 @@ MonoBehaviour: serializedPublicVariablesBytesString: Ai8AAAAAATIAAABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlAFQAYQBiAGwAZQAsACAAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4AAAAAAAYBAAAAAAAAACcBBAAAAHQAeQBwAGUAAWgAAABTAHkAcwB0AGUAbQAuAEMAbwBsAGwAZQBjAHQAaQBvAG4AcwAuAEcAZQBuAGUAcgBpAGMALgBMAGkAcwB0AGAAMQBbAFsAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4ALgBJAG4AdABlAHIAZgBhAGMAZQBzAC4ASQBVAGQAbwBuAFYAYQByAGkAYQBiAGwAZQAsACAAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4AXQBdACwAIABtAHMAYwBvAHIAbABpAGIAAQEJAAAAVgBhAHIAaQBhAGIAbABlAHMALwEAAAABaAAAAFMAeQBzAHQAZQBtAC4AQwBvAGwAbABlAGMAdABpAG8AbgBzAC4ARwBlAG4AZQByAGkAYwAuAEwAaQBzAHQAYAAxAFsAWwBWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAEkAbgB0AGUAcgBmAGEAYwBlAHMALgBJAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlACwAIABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgBdAF0ALAAgAG0AcwBjAG8AcgBsAGkAYgABAAAABgEAAAAAAAAAAi8CAAAAAUkAAABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlAGAAMQBbAFsAUwB5AHMAdABlAG0ALgBJAG4AdAAzADIALAAgAG0AcwBjAG8AcgBsAGkAYgBdAF0ALAAgAFYAUgBDAC4AVQBkAG8AbgAuAEMAbwBtAG0AbwBuAAIAAAAGAgAAAAAAAAAnAQQAAAB0AHkAcABlAAEXAAAAUwB5AHMAdABlAG0ALgBTAHQAcgBpAG4AZwAsACAAbQBzAGMAbwByAGwAaQBiACcBCgAAAFMAeQBtAGIAbwBsAE4AYQBtAGUAAR8AAABfAF8AXwBVAGQAbwBuAFMAaABhAHIAcABCAGUAaABhAHYAaQBvAHUAcgBWAGUAcgBzAGkAbwBuAF8AXwBfACcBBAAAAHQAeQBwAGUAARYAAABTAHkAcwB0AGUAbQAuAEkAbgB0ADMAMgAsACAAbQBzAGMAbwByAGwAaQBiABcBBQAAAFYAYQBsAHUAZQACAAAABwUHBQcF publicVariablesUnityEngineObjects: [] publicVariablesSerializationDataFormat: 0 +--- !u!1 &4909882456066066431 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4789832517991542133} + m_Layer: 0 + m_Name: Camera FOV Scaler + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4789832517991542133 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4909882456066066431} + 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: 5462889507286591849} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Scenes/witwics.unity b/Assets/Scenes/witwics.unity index 3780e0c..6ef93f0 100644 --- a/Assets/Scenes/witwics.unity +++ b/Assets/Scenes/witwics.unity @@ -1497,7 +1497,7 @@ PrefabInstance: m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: - - targetCorrespondingSourceObject: {fileID: 5462889507286591849, guid: b7be9e74a7f7fe24cb526bc367e85829, + - targetCorrespondingSourceObject: {fileID: 6802575006468162178, guid: b7be9e74a7f7fe24cb526bc367e85829, type: 3} insertIndex: -1 addedObject: {fileID: 1300477146} @@ -1521,6 +1521,12 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 609222593c2107c47884603707a4071a, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!4 &50383832 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 6802575006468162178, guid: b7be9e74a7f7fe24cb526bc367e85829, + type: 3} + m_PrefabInstance: {fileID: 50383829} + m_PrefabAsset: {fileID: 0} --- !u!1 &51134226 stripped GameObject: m_CorrespondingSourceObject: {fileID: 1705145681487634870, guid: e9914385266bca24db809c39e395f03c, @@ -9902,7 +9908,7 @@ PrefabInstance: m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: - - targetCorrespondingSourceObject: {fileID: 5462889507286591849, guid: b7be9e74a7f7fe24cb526bc367e85829, + - targetCorrespondingSourceObject: {fileID: 6802575006468162178, guid: b7be9e74a7f7fe24cb526bc367e85829, type: 3} insertIndex: -1 addedObject: {fileID: 1528283347} @@ -9926,6 +9932,12 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 609222593c2107c47884603707a4071a, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!4 &169430330 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 6802575006468162178, guid: b7be9e74a7f7fe24cb526bc367e85829, + type: 3} + m_PrefabInstance: {fileID: 169430327} + m_PrefabAsset: {fileID: 0} --- !u!1 &169542778 stripped GameObject: m_CorrespondingSourceObject: {fileID: 4032262213944914853, guid: be33bc7f6c414e6409becfa348b9310d, @@ -33915,8 +33927,8 @@ BoxCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 3 - m_Size: {x: 4.936206, y: 4.318262, z: 9.658502} - m_Center: {x: -0.93300486, y: 1.659131, z: -0.4586978} + m_Size: {x: 4.647025, y: 4.318262, z: 9.658502} + m_Center: {x: -0.7884145, y: 1.659131, z: -0.4586978} --- !u!1 &792054283 stripped GameObject: m_CorrespondingSourceObject: {fileID: 2410518288693767928, guid: 6587765855cbbb94c8cc3eb80d5956d6, @@ -52329,12 +52341,12 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1300477145} serializedVersion: 2 - m_LocalRotation: {x: -0.00000003090862, y: 0.70710677, z: -0.70710677, w: -0.00000003090862} - m_LocalPosition: {x: 0, y: -0, z: 0.321} - m_LocalScale: {x: 0.027999999, y: 1.1199999, z: 0.021000003} + m_LocalRotation: {x: -0.000000044703484, y: 0.7071068, z: -0.7071068, w: 0} + m_LocalPosition: {x: 0, y: 0, z: 0.32099998} + m_LocalScale: {x: 0.028, y: 1.1199996, z: 0.020999996} m_ConstrainProportionsScale: 1 m_Children: [] - m_Father: {fileID: 50383830} + m_Father: {fileID: 50383832} m_LocalEulerAnglesHint: {x: 90, y: 0, z: 180} --- !u!23 &1300477147 MeshRenderer: @@ -53707,8 +53719,8 @@ BoxCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 3 - m_Size: {x: 0.8664986, y: 4.318262, z: 9.658502} - m_Center: {x: -0.07990724, y: 1.659131, z: -0.4586978} + m_Size: {x: 1.9585377, y: 4.318262, z: 9.658502} + m_Center: {x: 0.46611232, y: 1.659131, z: -0.4586978} --- !u!1 &1331320732 GameObject: m_ObjectHideFlags: 0 @@ -64878,12 +64890,12 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1528283344} serializedVersion: 2 - m_LocalRotation: {x: 0, y: -0.7071068, z: 0.7071068, w: 0} - m_LocalPosition: {x: -0, y: -0, z: 0.406} - m_LocalScale: {x: 0.024999999, y: 1, z: 0.018750004} + m_LocalRotation: {x: -0.000000007450581, y: -0.7071068, z: 0.7071068, w: 0} + m_LocalPosition: {x: 0, y: 0, z: 0.406} + m_LocalScale: {x: 0.025, y: 1, z: 0.018750004} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 169430328} + m_Father: {fileID: 169430330} m_LocalEulerAnglesHint: {x: 90, y: 0, z: 180} --- !u!1 &1528591628 stripped GameObject: @@ -69639,6 +69651,11 @@ PrefabInstance: propertyPath: m_Name value: Player 1 Camera Anchor objectReference: {fileID: 0} + - target: {fileID: 4789832517991542133, guid: b7be9e74a7f7fe24cb526bc367e85829, + type: 3} + propertyPath: m_LocalScale.z + value: 0 + objectReference: {fileID: 0} - target: {fileID: 5462889507286591849, guid: b7be9e74a7f7fe24cb526bc367e85829, type: 3} propertyPath: m_LocalPosition.x diff --git a/Assets/UdonSharp/Cameras/CameraAnchor.asset b/Assets/UdonSharp/Cameras/CameraAnchor.asset index b44a2f3..349aa9c 100644 --- a/Assets/UdonSharp/Cameras/CameraAnchor.asset +++ b/Assets/UdonSharp/Cameras/CameraAnchor.asset @@ -44,7 +44,7 @@ MonoBehaviour: Data: - Name: Entry: 12 - Data: 10 + Data: 12 - Name: Entry: 7 Data: @@ -329,7 +329,7 @@ MonoBehaviour: Data: 20|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 - Data: 3 + Data: 2 - Name: Entry: 7 Data: 21|UnityEngine.SpaceAttribute, UnityEngine.CoreModule @@ -341,7 +341,61 @@ MonoBehaviour: Data: - Name: Entry: 7 - Data: 22|UnityEngine.TooltipAttribute, UnityEngine.CoreModule + Data: 22|UnityEngine.SerializeField, UnityEngine.CoreModule + - Name: + Entry: 8 + Data: + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: CameraFOVScaler + - Name: $v + Entry: 7 + Data: 23|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: k__BackingField + Entry: 1 + Data: CameraFOVScaler + - Name: k__BackingField + Entry: 9 + Data: 19 + - Name: k__BackingField + Entry: 9 + Data: 19 + - Name: k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 24|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 2 + - Name: + Entry: 7 + Data: 25|UnityEngine.TooltipAttribute, UnityEngine.CoreModule - Name: tooltip Entry: 1 Data: Changing the Z scale of this object will change the FOV of the attached @@ -351,7 +405,7 @@ MonoBehaviour: Data: - Name: Entry: 7 - Data: 23|UnityEngine.SerializeField, UnityEngine.CoreModule + Data: 26|UnityEngine.SerializeField, UnityEngine.CoreModule - Name: Entry: 8 Data: @@ -375,13 +429,13 @@ MonoBehaviour: Data: _AttachedCameraIndex - Name: $v Entry: 7 - Data: 24|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 27|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: _AttachedCameraIndex - Name: k__BackingField Entry: 7 - Data: 25|System.RuntimeType, mscorlib + Data: 28|System.RuntimeType, mscorlib - Name: Entry: 1 Data: System.Int32, mscorlib @@ -390,7 +444,7 @@ MonoBehaviour: Data: - Name: k__BackingField Entry: 9 - Data: 25 + Data: 28 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -405,13 +459,13 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 26|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + Data: 29|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 Data: 1 - Name: Entry: 7 - Data: 27|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime + Data: 30|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime - Name: Entry: 8 Data: @@ -433,72 +487,18 @@ MonoBehaviour: - Name: $k Entry: 1 Data: _AttachedCamera - - Name: $v - Entry: 7 - Data: 28|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - - Name: k__BackingField - Entry: 1 - Data: _AttachedCamera - - Name: k__BackingField - Entry: 7 - Data: 29|System.RuntimeType, mscorlib - - Name: - Entry: 1 - Data: UnityEngine.Camera, UnityEngine.CoreModule - - Name: - Entry: 8 - Data: - - Name: k__BackingField - Entry: 9 - Data: 29 - - Name: k__BackingField - Entry: 7 - Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib - - Name: - Entry: 6 - Data: - - Name: - Entry: 8 - Data: - - Name: k__BackingField - Entry: 5 - Data: false - - Name: _fieldAttributes - Entry: 7 - Data: 30|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - - Name: - Entry: 12 - Data: 0 - - Name: - Entry: 13 - Data: - - Name: - Entry: 8 - Data: - - Name: - Entry: 8 - Data: - - Name: - Entry: 8 - Data: - - Name: - Entry: 7 - Data: - - Name: $k - Entry: 1 - Data: _FollowedPlayerNames - Name: $v Entry: 7 Data: 31|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 - Data: _FollowedPlayerNames + Data: _AttachedCamera - Name: k__BackingField Entry: 7 Data: 32|System.RuntimeType, mscorlib - Name: Entry: 1 - Data: System.String[], mscorlib + Data: UnityEngine.Camera, UnityEngine.CoreModule - Name: Entry: 8 Data: @@ -540,19 +540,25 @@ MonoBehaviour: Data: - Name: $k Entry: 1 - Data: _FollowedPlayerNames_Cache + Data: _FollowedPlayerNames - Name: $v Entry: 7 Data: 34|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 - Data: _FollowedPlayerNames_Cache + Data: _FollowedPlayerNames - Name: k__BackingField - Entry: 9 - Data: 32 + Entry: 7 + Data: 35|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: System.String[], mscorlib + - Name: + Entry: 8 + Data: - Name: k__BackingField Entry: 9 - Data: 32 + Data: 35 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -567,7 +573,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 35|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + Data: 36|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 Data: 0 @@ -588,25 +594,19 @@ MonoBehaviour: Data: - Name: $k Entry: 1 - Data: _FollowedPlayers + Data: _FollowedPlayerNames_Cache - Name: $v Entry: 7 - Data: 36|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 37|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 - Data: _FollowedPlayers + Data: _FollowedPlayerNames_Cache - Name: k__BackingField - Entry: 7 - Data: 37|System.RuntimeType, mscorlib - - Name: - Entry: 1 - Data: VRC.SDKBase.VRCPlayerApi[], VRCSDKBase - - Name: - Entry: 8 - Data: + Entry: 9 + Data: 35 - Name: k__BackingField Entry: 9 - Data: 37 + Data: 35 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -637,6 +637,108 @@ MonoBehaviour: - Name: Entry: 8 Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _FollowedPlayers + - Name: $v + Entry: 7 + Data: 39|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: k__BackingField + Entry: 1 + Data: _FollowedPlayers + - Name: k__BackingField + Entry: 7 + Data: 40|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: VRC.SDKBase.VRCPlayerApi[], VRCSDKBase + - Name: + Entry: 8 + Data: + - Name: k__BackingField + Entry: 9 + Data: 40 + - Name: k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: k__BackingField + Entry: 5 + Data: false + - Name: _fieldAttributes + Entry: 7 + Data: 41|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _CameraFollowSpeed + - Name: $v + Entry: 7 + Data: 42|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: k__BackingField + Entry: 1 + Data: _CameraFollowSpeed + - Name: k__BackingField + Entry: 9 + Data: 8 + - Name: k__BackingField + Entry: 9 + Data: 8 + - Name: k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: k__BackingField + Entry: 5 + Data: false + - Name: _fieldAttributes + Entry: 7 + Data: 43|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: - Name: Entry: 13 Data: diff --git a/Assets/UdonSharp/Cameras/CameraAnchor.cs b/Assets/UdonSharp/Cameras/CameraAnchor.cs index d1dd696..0156017 100644 --- a/Assets/UdonSharp/Cameras/CameraAnchor.cs +++ b/Assets/UdonSharp/Cameras/CameraAnchor.cs @@ -2,7 +2,6 @@ using CameraSystem; using MMMaellon.LightSync; using UdonSharp; -using UnityEditor.Overlays; using UnityEngine; using VRC.SDKBase; using VRC.Udon.Common; @@ -17,8 +16,9 @@ public class CameraAnchor : UdonSharpBehaviour [SerializeField] private float NearClippingPlane = 0.3f; [SerializeField] private float FarClippingPlane = 1000.0f; [Space] - [Tooltip("Changing the Z scale of this object will change the FOV of the attached camera.")] [SerializeField] private Transform CameraRoot; + [Tooltip("Changing the Z scale of this object will change the FOV of the attached camera.")] + [SerializeField] private Transform CameraFOVScaler; [UdonSynced] private int _AttachedCameraIndex = -1; @@ -26,19 +26,23 @@ public class CameraAnchor : UdonSharpBehaviour private string[] _FollowedPlayerNames = new string[0]; private string[] _FollowedPlayerNames_Cache = new string[0]; private VRCPlayerApi[] _FollowedPlayers = new VRCPlayerApi[0]; + private float _CameraFollowSpeed = 1.0f; - void LateUpdate() + void Update() { if (_AttachedCamera) { - if (CameraRoot.childCount <= 0) + if (_AttachedCamera.transform.parent != CameraRoot) { + Debug.Log("[CameraAnchor] Camera has been detached from " + gameObject.name + "."); _AttachedCamera = null; + _AttachedCameraIndex = -1; + RequestSerialization(); } else { - _AttachedCamera.fieldOfView = FOV * CameraRoot.transform.localScale.z; + _AttachedCamera.fieldOfView = FOV * CameraFOVScaler.transform.localScale.z; } } @@ -57,8 +61,15 @@ public class CameraAnchor : UdonSharpBehaviour (LeftEyePosition.y + RightEyePosition.y + LeftFootPosition.y + RightFootPosition.y) / 4.0f, (LeftEyePosition.z + RightEyePosition.z + LeftFootPosition.z + RightFootPosition.z) / 4.0f); } + Vector3 CentroidAverage = CentroidSum / _FollowedPlayers.Length; - CameraRoot.LookAt(CentroidSum / _FollowedPlayers.Length, Vector3.up); + Vector3 LookDirection = (CentroidAverage - transform.position).normalized; + CameraRoot.transform.rotation = Quaternion.LookRotation( + Vector3.Lerp( + CameraRoot.transform.forward, + Vector3.RotateTowards(CameraRoot.transform.forward, LookDirection, 10.0f, 0.0f), + _CameraFollowSpeed / 10.0f) + ); } else { @@ -66,6 +77,7 @@ public class CameraAnchor : UdonSharpBehaviour } } + public override void OnDeserialization(DeserializationResult Result) { _AttachCamera_Synced(); @@ -74,6 +86,19 @@ public class CameraAnchor : UdonSharpBehaviour base.OnDeserialization(Result); } + public override void OnPlayerLeft(VRCPlayerApi LeavingPlayer) + { + //foreach (VRCPlayerApi FollowedPlayer in _FollowedPlayers) + //{ + // if (FollowedPlayer.displayName == LeavingPlayer.displayName) + // { + + // } + //} + + base.OnPlayerLeft(LeavingPlayer); + } + public void AttachCamera(Camera CameraComponent) { @@ -96,9 +121,10 @@ public class CameraAnchor : UdonSharpBehaviour } } - public void FollowPlayers(string[] Players) + public void FollowPlayers(string[] Players, float FollowSpeed = 1.0f) { _FollowedPlayerNames = Players; + _CameraFollowSpeed = FollowSpeed; _FollowPlayers_Synced(); RequestSerialization(); } @@ -113,16 +139,19 @@ public class CameraAnchor : UdonSharpBehaviour private void _AttachCamera_Synced() { - Camera NewCamera = CameraSystemManager.camerasObjects[_AttachedCameraIndex]; - if (NewCamera != _AttachedCamera) + if (_AttachedCameraIndex >= 0) { - _AttachedCamera = NewCamera; - _AttachedCamera.gameObject.SetActive(true); - _AttachedCamera.transform.parent = CameraRoot; - _AttachedCamera.fieldOfView = FOV; - _AttachedCamera.nearClipPlane = NearClippingPlane; - _AttachedCamera.farClipPlane = FarClippingPlane; - _AttachedCamera.GetComponent().TeleportToLocalSpace(Vector3.zero, Quaternion.identity, true); + Camera NewCamera = CameraSystemManager.camerasObjects[_AttachedCameraIndex]; + if (NewCamera != _AttachedCamera) + { + _AttachedCamera = NewCamera; + _AttachedCamera.gameObject.SetActive(true); + _AttachedCamera.transform.parent = CameraRoot; + _AttachedCamera.fieldOfView = FOV; + _AttachedCamera.nearClipPlane = NearClippingPlane; + _AttachedCamera.farClipPlane = FarClippingPlane; + _AttachedCamera.GetComponent().TeleportToLocalSpace(Vector3.zero, Quaternion.identity, true); + } } } diff --git a/Assets/UdonSharp/Cameras/CameraControllerRound3.cs b/Assets/UdonSharp/Cameras/CameraControllerRound3.cs index 65344e2..b577972 100644 --- a/Assets/UdonSharp/Cameras/CameraControllerRound3.cs +++ b/Assets/UdonSharp/Cameras/CameraControllerRound3.cs @@ -117,18 +117,18 @@ public class CameraControllerRound3 : CameraControllerBase } - public void OverheadCamera_FollowPlayers(string[] Players) + public void OverheadCamera_FollowPlayers(string[] Players, float FollowSpeed = 1.0f) { - OverheadCameraAnchor.FollowPlayers(Players); + OverheadCameraAnchor.FollowPlayers(Players, FollowSpeed); } public void OverheadCamera_StopFollowingPlayers() { OverheadCameraAnchor.StopFollowingPlayers(); } - public void FrontCamera_FollowPlayers(string[] Players) + public void FrontCamera_FollowPlayers(string[] Players, float FollowSpeed = 1.0f) { - FrontCameraAnchor.FollowPlayers(Players); + FrontCameraAnchor.FollowPlayers(Players, FollowSpeed); } public void FrontCamera_StopFollowingPlayers() { diff --git a/Assets/UdonSharp/Game Managers/GameManagerRound3.cs b/Assets/UdonSharp/Game Managers/GameManagerRound3.cs index fda9fb8..d1457d7 100644 --- a/Assets/UdonSharp/Game Managers/GameManagerRound3.cs +++ b/Assets/UdonSharp/Game Managers/GameManagerRound3.cs @@ -1,7 +1,6 @@  using UdonSharp; using UnityEngine; -using UnityEngine.Video; using VRC.SDK3.Data; using VRC.SDK3.UdonNetworkCalling; using VRC.SDKBase; @@ -96,6 +95,8 @@ public class GameManagerRound3 : GameManagerBase _CameraControllerRound3.InitialiseCameras(); _CameraControllerRound3.PlayIFeelGood(true); + DeinitialiseGameplayCameraFollowers(); + DeinitialiseEndingCameraFollowers(); RequestSerialization(); } @@ -200,6 +201,8 @@ public class GameManagerRound3 : GameManagerBase _CameraControllerRound3.DisableAllSwitchers(); _CameraControllerRound3.HostPlayerTimerToggle.Activate = false; _CameraControllerRound3.ActivatePlayfieldSwitchTriggerGroup = true; + InitialiseGameplayCameraFollowers(); + GetCurrentMarker().SendCustomNetworkEvent(NetworkEventTarget.Owner, "Activated", true); _EndingPlayer.LoadRandomVideo(); @@ -231,7 +234,7 @@ public class GameManagerRound3 : GameManagerBase _Timer--; if (_Timer < 0) { - SendCustomNetworkEvent(NetworkEventTarget.Owner, nameof(GameHasBeenLost), false); + SendCustomNetworkEvent(NetworkEventTarget.Owner, nameof(GameIsOver), false, false); return; } @@ -252,7 +255,7 @@ public class GameManagerRound3 : GameManagerBase SuccessCounter++; if (SuccessCounter >= MAX_SUCCESS_COUNT) { - GameHasBeenWon(); + GameIsOver(true, false); } else { @@ -323,7 +326,7 @@ public class GameManagerRound3 : GameManagerBase if (ActiveMarker >= FloorMap.MAX_SELECTED_COUNTRIES) { // If we ran out of countries, lose the game here. - SendCustomNetworkEvent(NetworkEventTarget.Owner, nameof(GameHasBeenLost), true); + SendCustomNetworkEvent(NetworkEventTarget.Owner, nameof(GameIsOver), false, true); return; } @@ -335,7 +338,21 @@ public class GameManagerRound3 : GameManagerBase } [NetworkCallable] - public void GameHasBeenWon() + public void GameIsOver(bool GameWon, bool HaveWeRunOutOfMarkers) + { + if (GameWon) + { + _GameHasBeenWon(); + } + else + { + _GameHasBeenLost(HaveWeRunOutOfMarkers); + } + + InitialiseEndingCameraFollowers(); + } + + private void _GameHasBeenWon() { _RunTimer = false; @@ -380,18 +397,17 @@ public class GameManagerRound3 : GameManagerBase _NewspaperPublicDisplay.Activate(true); } - [NetworkCallable] - public void GameHasBeenLost(bool RanOutOfMarkers) + private void _GameHasBeenLost(bool HaveWeRunOutOfMarkers) { _RunTimer = false; if (_GameStatus == GameStatus.Begin) { - GameStatusUpdate(RanOutOfMarkers ? GameStatus.RanOutOfMarkers : GameStatus.RanOutOfTime); + GameStatusUpdate(HaveWeRunOutOfMarkers ? GameStatus.RanOutOfMarkers : GameStatus.RanOutOfTime); HostCardBetweenRoundsInterface GameLossInterface = (HostCardBetweenRoundsInterface)GetHostCardInterface(RoundSegmentType.BetweenSegments); - GameLossInterface.HeaderUI.text = "The player has run out of " + (RanOutOfMarkers ? "markers" : "time") + "."; + GameLossInterface.HeaderUI.text = "The player has run out of " + (HaveWeRunOutOfMarkers ? "markers" : "time") + "."; GameLossInterface.CommentUI.text = "- Found " + SuccessCounter + " countries in " + TIMER_LENGTH + " seconds.\n\n" + "- There's one more thing I want you to do for us. You know what it is..."; @@ -477,7 +493,7 @@ public class GameManagerRound3 : GameManagerBase _EndingPlayer.PlayVideo = false; _AudioManager.SendCustomNetworkEvent(NetworkEventTarget.All, "FadeOutMusic"); - _CameraControllerRound3.SwitchToOverheadCamera(); + _CameraControllerRound3.SwitchToFrontCamera(); _CameraControllerRound3.DeinitialiseCameras(); _CaseManager.EndGame(); @@ -546,6 +562,30 @@ public class GameManagerRound3 : GameManagerBase return CurrentWinner[0]; } + private void InitialiseGameplayCameraFollowers() + { + _CameraControllerRound3.FrontCamera_FollowPlayers(new string[1] { GetRound3PlayerName() }); + } + private void DeinitialiseGameplayCameraFollowers() + { + _CameraControllerRound3.FrontCamera_StopFollowingPlayers(); + } + + private void InitialiseEndingCameraFollowers() + { + string[] PlayerFollows = new string[2] { + _CaseManager.GetHostOwner().displayName, + GetRound3PlayerName() + }; + + _CameraControllerRound3.FrontCamera_FollowPlayers(PlayerFollows); + _CameraControllerRound3.OverheadCamera_FollowPlayers(PlayerFollows); + } + private void DeinitialiseEndingCameraFollowers() + { + _CameraControllerRound3.OverheadCamera_StopFollowingPlayers(); + } + protected override HostCardInterfaceBase GetHostCardInterface(RoundSegmentType Question) {