From 96860632ff81b5fdbfa52469810cb05ea42ce2c0 Mon Sep 17 00:00:00 2001 From: Cinder Foster-Smith Date: Mon, 15 Feb 2021 18:09:32 +0000 Subject: [PATCH] Feature/character controller --- game/Assets/Prefabs/Player.prefab | 501 ++++++++------ game/Assets/Prefabs/Player.prefab.meta | 2 +- game/Assets/Scenes/Main.unity | 622 +++++------------- game/Assets/Scripts/Input/BufferedInput.cs | 36 +- .../Assets/Scripts/Player/PlayerController.cs | 277 +++++++- .../Scripts/Player/PlayerInputHandler.cs | 42 +- .../Scripts/Player/PlayerInputSettings.cs | 30 +- .../Scripts/Player/PlayerMovementSettings.cs | 64 +- game/Assets/Scripts/Player/PlayerPower.cs | 71 ++ .../Assets/Scripts/Player/PlayerPower.cs.meta | 11 + game/Assets/Scripts/Player/PlayerPowers.cs | 30 + .../Scripts/Player/PlayerPowers.cs.meta | 11 + game/Assets/Scripts/Util/MathsExtensions.cs | 21 + .../Scripts/Util/MathsExtensions.cs.meta | 11 + .../Input/PlayerControls.inputactions | 32 +- .../Settings/Player/PlayerInputSettings.asset | 5 +- .../Player/PlayerMovementSettings.asset | 17 +- game/Assets/Settings/Player/Powers.meta | 8 + .../Assets/Settings/Player/Powers/Blink.asset | 17 + .../Settings/Player/Powers/Blink.asset.meta | 8 + .../Assets/Settings/Player/Powers/Boost.asset | 15 + .../Settings/Player/Powers/Boost.asset.meta | 8 + game/ProjectSettings/ProjectSettings.asset | 3 +- 23 files changed, 1134 insertions(+), 708 deletions(-) create mode 100644 game/Assets/Scripts/Player/PlayerPower.cs create mode 100644 game/Assets/Scripts/Player/PlayerPower.cs.meta create mode 100644 game/Assets/Scripts/Player/PlayerPowers.cs create mode 100644 game/Assets/Scripts/Player/PlayerPowers.cs.meta create mode 100644 game/Assets/Scripts/Util/MathsExtensions.cs create mode 100644 game/Assets/Scripts/Util/MathsExtensions.cs.meta create mode 100644 game/Assets/Settings/Player/Powers.meta create mode 100644 game/Assets/Settings/Player/Powers/Blink.asset create mode 100644 game/Assets/Settings/Player/Powers/Blink.asset.meta create mode 100644 game/Assets/Settings/Player/Powers/Boost.asset create mode 100644 game/Assets/Settings/Player/Powers/Boost.asset.meta diff --git a/game/Assets/Prefabs/Player.prefab b/game/Assets/Prefabs/Player.prefab index 390c17d..b6ff71b 100644 --- a/game/Assets/Prefabs/Player.prefab +++ b/game/Assets/Prefabs/Player.prefab @@ -1,6 +1,6 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: ---- !u!1 &1865034783 +--- !u!1 &13726836532781110 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -8,46 +8,45 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 1865034784} - - component: {fileID: 1865034787} - - component: {fileID: 1865034786} - - component: {fileID: 1865034785} + - component: {fileID: 13726836532781129} + - component: {fileID: 13726836532781131} + - component: {fileID: 13726836532781128} m_Layer: 0 - m_Name: Cube + m_Name: Cylinder m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!4 &1865034784 +--- !u!4 &13726836532781129 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1865034783} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0.5, z: 0.6} - m_LocalScale: {x: 0.1, y: 0.1, z: 0.1} + m_GameObject: {fileID: 13726836532781110} + m_LocalRotation: {x: 0.7071068, y: -0, z: -0, w: 0.7071068} + m_LocalPosition: {x: 0, y: 0.5, z: 0.177} + m_LocalScale: {x: 0.65, y: 0.4, z: 0.5} m_Children: [] - m_Father: {fileID: 7846295001490405682} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!33 &1865034787 + m_Father: {fileID: 13726837642651460} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} +--- !u!33 &13726836532781131 MeshFilter: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1865034783} - m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} ---- !u!23 &1865034786 + m_GameObject: {fileID: 13726836532781110} + m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &13726836532781128 MeshRenderer: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1865034783} + m_GameObject: {fileID: 13726836532781110} m_Enabled: 1 m_CastShadows: 1 m_ReceiveShadows: 1 @@ -60,7 +59,7 @@ MeshRenderer: m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: - - {fileID: 2100000, guid: 1b0f58118cf7a5a4e85fda00fe3de44b, type: 2} + - {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -82,20 +81,7 @@ MeshRenderer: m_SortingLayer: 0 m_SortingOrder: 0 m_AdditionalVertexStreams: {fileID: 0} ---- !u!65 &1865034785 -BoxCollider: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1865034783} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 1 - serializedVersion: 2 - m_Size: {x: 1, y: 1, z: 1} - m_Center: {x: 0, y: 0, z: 0} ---- !u!1 &7846295001045979005 +--- !u!1 &13726836969441781 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -103,11 +89,12 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 7846295001045979004} - - component: {fileID: 7846295001045979006} - - component: {fileID: 7846295001045978993} - - component: {fileID: 7846295001045978992} - - component: {fileID: 7846295000056357947} + - component: {fileID: 13726836969441544} + - component: {fileID: 13726836969441545} + - component: {fileID: 13726836969441783} + - component: {fileID: 13726836969441780} + - component: {fileID: 13726836969441782} + - component: {fileID: 13726837176080779} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -115,45 +102,71 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!4 &7846295001045979004 +--- !u!4 &13726836969441544 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7846295001045979005} + m_GameObject: {fileID: 13726836969441781} 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_Children: - - {fileID: 7846295001490405682} - - {fileID: 7846295001499866554} + - {fileID: 13726837642651460} + - {fileID: 13726837293638830} m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &7846295001045979006 +--- !u!143 &13726836969441545 +CharacterController: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 13726836969441781} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 1.7 + m_Radius: 0.4 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.01 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0.85, z: 0} +--- !u!114 &13726836969441783 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7846295001045979005} + m_GameObject: {fileID: 13726836969441781} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: a734b8e2d64ba604795fd5cef5d741f4, type: 3} m_Name: m_EditorClassIdentifier: _movementSettings: {fileID: 11400000, guid: 0c168708f93291545b51df2eec8f4ac3, type: 2} - _inputHandler: {fileID: 7846295001045978992} - _controller: {fileID: 7846295000056357947} - _graphics: {fileID: 7846295001490405682} ---- !u!114 &7846295001045978993 + _inputHandler: {fileID: 13726836969441782} + _controller: {fileID: 13726836969441545} + _powers: {fileID: 13726837176080779} + _graphics: {fileID: 13726837642651460} + _renderers: + - {fileID: 13726837642651463} + - {fileID: 13726836532781128} + _groundedColor: {r: 0, g: 1, b: 0.39492488, a: 0} + _jumpColor: {r: 1, g: 0.95084643, b: 0, a: 0} + _boostColor: {r: 1, g: 0, b: 0.9173207, a: 0} + _exhaustedColor: {r: 1, g: 0, b: 0, a: 0} +--- !u!114 &13726836969441780 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7846295001045979005} + m_GameObject: {fileID: 13726836969441781} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 62899f850307741f2a39c98a8b639597, type: 3} @@ -174,7 +187,7 @@ MonoBehaviour: m_ActionEvents: - m_PersistentCalls: m_Calls: - - m_Target: {fileID: 7846295001045978992} + - m_Target: {fileID: 13726836969441782} m_TargetAssemblyTypeName: PlayerInputHandler, Assembly-CSharp m_MethodName: Move m_Mode: 0 @@ -190,7 +203,7 @@ MonoBehaviour: m_ActionName: CoreMap/Move[/Keyboard/w,/Keyboard/s,/Keyboard/a,/Keyboard/d,/XInputControllerWindows/leftStick] - m_PersistentCalls: m_Calls: - - m_Target: {fileID: 7846295001045978992} + - m_Target: {fileID: 13726836969441782} m_TargetAssemblyTypeName: PlayerInputHandler, Assembly-CSharp m_MethodName: Look m_Mode: 0 @@ -206,7 +219,7 @@ MonoBehaviour: m_ActionName: CoreMap/Look[/Mouse/delta,/XInputControllerWindows/rightStick] - m_PersistentCalls: m_Calls: - - m_Target: {fileID: 7846295001045978992} + - m_Target: {fileID: 13726836969441782} m_TargetAssemblyTypeName: PlayerInputHandler, Assembly-CSharp m_MethodName: Jump m_Mode: 0 @@ -222,7 +235,7 @@ MonoBehaviour: m_ActionName: CoreMap/Jump[/Keyboard/space,/XInputControllerWindows/buttonSouth] - m_PersistentCalls: m_Calls: - - m_Target: {fileID: 7846295001045978992} + - m_Target: {fileID: 13726836969441782} m_TargetAssemblyTypeName: PlayerInputHandler, Assembly-CSharp m_MethodName: Use m_Mode: 0 @@ -236,43 +249,57 @@ MonoBehaviour: m_CallState: 2 m_ActionId: 2bbc2e93-6016-4544-8399-0c4ee222850c m_ActionName: CoreMap/Use[/Keyboard/e,/XInputControllerWindows/buttonWest] + - m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 13726836969441782} + m_TargetAssemblyTypeName: PlayerInputHandler, Assembly-CSharp + m_MethodName: Blink + m_Mode: 0 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + m_ActionId: 0eb55067-1328-4b0a-9494-b427befe049a + m_ActionName: CoreMap/New action m_NeverAutoSwitchControlSchemes: 1 m_DefaultControlScheme: Gamepad m_DefaultActionMap: CoreMap m_SplitScreenIndex: -1 - m_Camera: {fileID: 7846295001499866555} ---- !u!114 &7846295001045978992 + m_Camera: {fileID: 13726837293638818} +--- !u!114 &13726836969441782 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7846295001045979005} + m_GameObject: {fileID: 13726836969441781} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: e12816fc78a8ca3429be019aa4e51fdd, type: 3} m_Name: m_EditorClassIdentifier: _inputSettings: {fileID: 11400000, guid: 09b165d6ce14f86459be7213da9688a7, type: 2} ---- !u!143 &7846295000056357947 -CharacterController: +--- !u!114 &13726837176080779 +MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7846295001045979005} - m_Material: {fileID: 0} - m_IsTrigger: 0 + m_GameObject: {fileID: 13726836969441781} m_Enabled: 1 - serializedVersion: 2 - m_Height: 2 - m_Radius: 0.5 - m_SlopeLimit: 45 - m_StepOffset: 0.3 - m_SkinWidth: 0.01 - m_MinMoveDistance: 0.001 - m_Center: {x: 0, y: 1, z: 0} ---- !u!1 &7846295001490405694 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0e73a47345d899f4ca1e5e08683c2b82, type: 3} + m_Name: + m_EditorClassIdentifier: + _cheatBlink: 0 + _cheatBoost: 0 + _blink: {fileID: 11400000, guid: b47ea197a7cc2ed4eb15271cef672997, type: 2} + _boost: {fileID: 11400000, guid: d5ed942937d8cca478f3ec97f6b9c8a2, type: 2} +--- !u!1 &13726837293638831 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -280,9 +307,140 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 7846295001490405682} - - component: {fileID: 7846295001490405683} - - component: {fileID: 7846295001490405680} + - component: {fileID: 13726837293638830} + - component: {fileID: 13726837293638818} + - component: {fileID: 13726837293638819} + - component: {fileID: 13726837293638816} + - component: {fileID: 13726837293638817} + m_Layer: 0 + m_Name: Camera + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &13726837293638830 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 13726837293638831} + 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_Children: [] + m_Father: {fileID: 13726836969441544} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!20 &13726837293638818 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 13726837293638831} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!81 &13726837293638819 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 13726837293638831} + m_Enabled: 1 +--- !u!114 &13726837293638816 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 13726837293638831} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_RenderShadows: 1 + m_RequiresDepthTextureOption: 2 + m_RequiresOpaqueTextureOption: 2 + m_CameraType: 0 + m_Cameras: [] + m_RendererIndex: -1 + m_VolumeLayerMask: + serializedVersion: 2 + m_Bits: 1 + m_VolumeTrigger: {fileID: 0} + m_RenderPostProcessing: 0 + m_Antialiasing: 0 + m_AntialiasingQuality: 2 + m_StopNaN: 0 + m_Dithering: 0 + m_ClearDepth: 1 + m_AllowXRRendering: 1 + m_RequiresDepthTexture: 0 + m_RequiresColorTexture: 0 + m_Version: 2 +--- !u!114 &13726837293638817 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 13726837293638831} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 805caadbe4df94a40bf7ddb70bea02f6, type: 3} + m_Name: + m_EditorClassIdentifier: + _settings: {fileID: 11400000, guid: 995f378ab762cd344b7a6d108f049191, type: 2} + _inputHandler: {fileID: 13726836969441782} +--- !u!1 &13726837642651461 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 13726837642651460} + - component: {fileID: 13726837642651462} + - component: {fileID: 13726837642651463} m_Layer: 0 m_Name: Graphics m_TagString: Untagged @@ -290,36 +448,37 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!4 &7846295001490405682 +--- !u!4 &13726837642651460 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7846295001490405694} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 1, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} + m_GameObject: {fileID: 13726837642651461} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0.85, z: 0} + m_LocalScale: {x: 0.8, y: 0.85, z: 0.8} m_Children: - - {fileID: 1865034784} - m_Father: {fileID: 7846295001045979004} + - {fileID: 3910566560202895193} + - {fileID: 13726836532781129} + m_Father: {fileID: 13726836969441544} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!33 &7846295001490405683 +--- !u!33 &13726837642651462 MeshFilter: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7846295001490405694} + m_GameObject: {fileID: 13726837642651461} m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0} ---- !u!23 &7846295001490405680 +--- !u!23 &13726837642651463 MeshRenderer: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7846295001490405694} + m_GameObject: {fileID: 13726837642651461} m_Enabled: 1 m_CastShadows: 1 m_ReceiveShadows: 1 @@ -332,7 +491,7 @@ MeshRenderer: m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: - - {fileID: 2100000, guid: 1b0f58118cf7a5a4e85fda00fe3de44b, type: 2} + - {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -354,7 +513,7 @@ MeshRenderer: m_SortingLayer: 0 m_SortingOrder: 0 m_AdditionalVertexStreams: {fileID: 0} ---- !u!1 &7846295001499866553 +--- !u!1 &2625718689509414053 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -362,126 +521,88 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 7846295001499866554} - - component: {fileID: 7846295001499866555} - - component: {fileID: 7846295001499866552} - - component: {fileID: 7846295001499866557} - - component: {fileID: 7846295001499866556} + - component: {fileID: 3910566560202895193} + - component: {fileID: 7229600687471556246} m_Layer: 0 - m_Name: PlayerCamera - m_TagString: MainCamera + m_Name: Spot Light + m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!4 &7846295001499866554 +--- !u!4 &3910566560202895193 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7846295001499866553} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 1, z: -10} - m_LocalScale: {x: 1, y: 1, z: 1} + m_GameObject: {fileID: 2625718689509414053} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0.50000006, z: 0.013} + m_LocalScale: {x: 0.65, y: 0.39999998, z: 0.49999997} m_Children: [] - m_Father: {fileID: 7846295001045979004} - m_RootOrder: 1 + m_Father: {fileID: 13726837642651460} + m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!20 &7846295001499866555 -Camera: +--- !u!108 &7229600687471556246 +Light: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7846295001499866553} + m_GameObject: {fileID: 2625718689509414053} m_Enabled: 1 - serializedVersion: 2 - m_ClearFlags: 1 - m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} - m_projectionMatrixMode: 1 - m_GateFitMode: 2 - m_FOVAxisMode: 0 - m_SensorSize: {x: 36, y: 24} - m_LensShift: {x: 0, y: 0} - m_FocalLength: 50 - m_NormalizedViewPortRect: - serializedVersion: 2 - x: 0 - y: 0 - width: 1 - height: 1 - near clip plane: 0.3 - far clip plane: 1000 - field of view: 65 - orthographic: 0 - orthographic size: 5 - m_Depth: -1 + serializedVersion: 10 + m_Type: 0 + m_Shape: 0 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 2 + m_Range: 10 + m_SpotAngle: 116.77128 + m_InnerSpotAngle: 41.896492 + m_CookieSize: 10 + m_Shadows: + m_Type: 2 + m_Resolution: -1 + m_CustomResolution: -1 + m_Strength: 1 + m_Bias: 0.02 + m_NormalBias: 0.1 + m_NearPlane: 0.1 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 m_CullingMask: serializedVersion: 2 m_Bits: 4294967295 - m_RenderingPath: -1 - m_TargetTexture: {fileID: 0} - m_TargetDisplay: 0 - m_TargetEye: 3 - m_HDR: 1 - m_AllowMSAA: 1 - m_AllowDynamicResolution: 0 - m_ForceIntoRT: 0 - m_OcclusionCulling: 1 - m_StereoConvergence: 10 - m_StereoSeparation: 0.022 ---- !u!81 &7846295001499866552 -AudioListener: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7846295001499866553} - m_Enabled: 1 ---- !u!114 &7846295001499866557 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7846295001499866553} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3} - m_Name: - m_EditorClassIdentifier: - m_RenderShadows: 1 - m_RequiresDepthTextureOption: 2 - m_RequiresOpaqueTextureOption: 2 - m_CameraType: 0 - m_Cameras: [] - m_RendererIndex: 0 - m_VolumeLayerMask: - serializedVersion: 2 - m_Bits: 1 - m_VolumeTrigger: {fileID: 0} - m_RenderPostProcessing: 1 - m_Antialiasing: 0 - m_AntialiasingQuality: 2 - m_StopNaN: 0 - m_Dithering: 0 - m_ClearDepth: 1 - m_AllowXRRendering: 1 - m_RequiresDepthTexture: 0 - m_RequiresColorTexture: 0 - m_Version: 2 ---- !u!114 &7846295001499866556 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7846295001499866553} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 805caadbe4df94a40bf7ddb70bea02f6, type: 3} - m_Name: - m_EditorClassIdentifier: - _settings: {fileID: 11400000, guid: 995f378ab762cd344b7a6d108f049191, type: 2} - _inputHandler: {fileID: 7846295001045978992} + m_RenderingLayerMask: 1 + m_Lightmapping: 4 + m_LightShadowCasterMode: 0 + m_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ColorTemperature: 6570 + m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 + m_UseViewFrustumForShadowCasterCull: 1 + m_ShadowRadius: 0 + m_ShadowAngle: 0 diff --git a/game/Assets/Prefabs/Player.prefab.meta b/game/Assets/Prefabs/Player.prefab.meta index edbe640..b6db2b2 100644 --- a/game/Assets/Prefabs/Player.prefab.meta +++ b/game/Assets/Prefabs/Player.prefab.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: ed6e7ba262c00374d9ed95757ea54c05 +guid: 5efe0b059275dbe48a4108d03ad03fd9 PrefabImporter: externalObjects: {} userData: diff --git a/game/Assets/Scenes/Main.unity b/game/Assets/Scenes/Main.unity index 45eda93..28989dc 100644 --- a/game/Assets/Scenes/Main.unity +++ b/game/Assets/Scenes/Main.unity @@ -212,11 +212,11 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 349701919} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0.56895196, y: -1.2437972, z: -4.8898325} m_LocalScale: {x: 1000, y: 100, z: 1000} m_Children: [] - m_Father: {fileID: 0} + m_Father: {fileID: 1509348081} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &470223356 @@ -307,12 +307,12 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 470223356} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 13.2, y: 1, z: 30.28} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 12.631048, y: -0.24379718, z: 25.390167} m_LocalScale: {x: 2, y: 2, z: 2} m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 7 + m_Father: {fileID: 1509348081} + m_RootOrder: 6 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &472872962 GameObject: @@ -349,7 +349,7 @@ Light: m_InnerSpotAngle: 21.80208 m_CookieSize: 10 m_Shadows: - m_Type: 2 + m_Type: 1 m_Resolution: -1 m_CustomResolution: -1 m_Strength: 1 @@ -382,7 +382,7 @@ Light: serializedVersion: 2 m_Bits: 4294967295 m_RenderingLayerMask: 1 - m_Lightmapping: 4 + m_Lightmapping: 1 m_LightShadowCasterMode: 0 m_AreaSize: {x: 1, y: 1} m_BounceIntensity: 1 @@ -401,56 +401,12 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 472872962} m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} - m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalPosition: {x: -0.56895196, y: 1.7562028, z: -4.8898325} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] - m_Father: {fileID: 0} + m_Father: {fileID: 1509348081} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} ---- !u!1 &1112831115 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1112831116} - - component: {fileID: 1112831117} - m_Layer: 0 - m_Name: Loader - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &1112831116 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1112831115} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 365.90356, y: 869.2481, z: 2025.6278} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 8 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &1112831117 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1112831115} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 91e277ce4b818ac4fb67c516e77c391b, type: 3} - m_Name: - m_EditorClassIdentifier: - _sceneType: 3 --- !u!1 &1148358018 GameObject: m_ObjectHideFlags: 0 @@ -539,12 +495,12 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1148358018} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -1.85, y: 1, z: -6.81} - m_LocalScale: {x: 2, y: 2, z: 2} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -2.418952, y: -0.7437972, z: -11.699833} + m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 5 + m_Father: {fileID: 1509348081} + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1191416068 GameObject: @@ -587,222 +543,14 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1191416068} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -2.5060086, y: 0.33582032, z: 0.57440275} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -3.0749607, y: -0.90797687, z: -4.3154297} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 3 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &1292675908 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1292675909} - - component: {fileID: 1292675910} - - component: {fileID: 1292675911} - - component: {fileID: 1292675912} - - component: {fileID: 1292675913} - - component: {fileID: 1292675914} - - component: {fileID: 1292675915} - m_Layer: 0 - m_Name: Player - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &1292675909 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1292675908} - 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_Children: - - {fileID: 1468685579} - - {fileID: 1444606339} - m_Father: {fileID: 0} + m_Father: {fileID: 1509348081} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!136 &1292675910 -CapsuleCollider: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1292675908} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 1 - m_Radius: 0.5 - m_Height: 2 - m_Direction: 1 - m_Center: {x: 0, y: 1, z: 0} ---- !u!114 &1292675911 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1292675908} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: a734b8e2d64ba604795fd5cef5d741f4, type: 3} - m_Name: - m_EditorClassIdentifier: - _movementSettings: {fileID: 11400000, guid: 0c168708f93291545b51df2eec8f4ac3, type: 2} - _inputHandler: {fileID: 1292675913} - _rigidbody: {fileID: 1292675914} ---- !u!114 &1292675912 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1292675908} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 62899f850307741f2a39c98a8b639597, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Actions: {fileID: -944628639613478452, guid: d4d9eb5db7beac84ca3cb36cfc09cd0a, type: 3} - m_NotificationBehavior: 2 - m_UIInputModule: {fileID: 0} - m_DeviceLostEvent: - m_PersistentCalls: - m_Calls: [] - m_DeviceRegainedEvent: - m_PersistentCalls: - m_Calls: [] - m_ControlsChangedEvent: - m_PersistentCalls: - m_Calls: [] - m_ActionEvents: - - m_PersistentCalls: - m_Calls: - - m_Target: {fileID: 1292675913} - m_TargetAssemblyTypeName: PlayerInputHandler, Assembly-CSharp - m_MethodName: Move - m_Mode: 0 - m_Arguments: - m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine - m_IntArgument: 0 - m_FloatArgument: 0 - m_StringArgument: - m_BoolArgument: 0 - m_CallState: 2 - m_ActionId: 5c440996-60ec-4084-9223-75d39638108a - m_ActionName: CoreMap/Move[/Keyboard/w,/Keyboard/s,/Keyboard/a,/Keyboard/d,/XInputControllerWindows/leftStick] - - m_PersistentCalls: - m_Calls: - - m_Target: {fileID: 1292675913} - m_TargetAssemblyTypeName: PlayerInputHandler, Assembly-CSharp - m_MethodName: Look - m_Mode: 0 - m_Arguments: - m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine - m_IntArgument: 0 - m_FloatArgument: 0 - m_StringArgument: - m_BoolArgument: 0 - m_CallState: 2 - m_ActionId: d271942b-8516-4550-88ae-552350feb4b1 - m_ActionName: CoreMap/Look[/Mouse/delta,/XInputControllerWindows/rightStick] - - m_PersistentCalls: - m_Calls: - - m_Target: {fileID: 1292675913} - m_TargetAssemblyTypeName: PlayerInputHandler, Assembly-CSharp - m_MethodName: Jump - m_Mode: 0 - m_Arguments: - m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine - m_IntArgument: 0 - m_FloatArgument: 0 - m_StringArgument: - m_BoolArgument: 0 - m_CallState: 2 - m_ActionId: da936947-fcfa-4872-a4e3-15763afe56b6 - m_ActionName: CoreMap/Jump[/Keyboard/space,/XInputControllerWindows/buttonSouth] - - m_PersistentCalls: - m_Calls: - - m_Target: {fileID: 1292675913} - m_TargetAssemblyTypeName: PlayerInputHandler, Assembly-CSharp - m_MethodName: Use - m_Mode: 0 - m_Arguments: - m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine - m_IntArgument: 0 - m_FloatArgument: 0 - m_StringArgument: - m_BoolArgument: 0 - m_CallState: 2 - m_ActionId: 2bbc2e93-6016-4544-8399-0c4ee222850c - m_ActionName: CoreMap/Use[/Keyboard/e,/XInputControllerWindows/buttonWest] - m_NeverAutoSwitchControlSchemes: 0 - m_DefaultControlScheme: - m_DefaultActionMap: CoreMap - m_SplitScreenIndex: -1 - m_Camera: {fileID: 1444606338} ---- !u!114 &1292675913 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1292675908} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e12816fc78a8ca3429be019aa4e51fdd, type: 3} - m_Name: - m_EditorClassIdentifier: - _inputSettings: {fileID: 11400000, guid: 09b165d6ce14f86459be7213da9688a7, type: 2} ---- !u!54 &1292675914 -Rigidbody: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1292675908} - serializedVersion: 2 - m_Mass: 1 - m_Drag: 0 - m_AngularDrag: 0.05 - m_UseGravity: 1 - m_IsKinematic: 1 - m_Interpolate: 0 - m_Constraints: 112 - m_CollisionDetection: 0 ---- !u!143 &1292675915 -CharacterController: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1292675908} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 1 - serializedVersion: 2 - m_Height: 2 - m_Radius: 0.5 - m_SlopeLimit: 45 - m_StepOffset: 0.3 - m_SkinWidth: 0.08 - m_MinMoveDistance: 0.001 - m_Center: {x: 0, y: 0, z: 0} ---- !u!1 &1444606336 +--- !u!1 &1509348080 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -810,209 +558,34 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 1444606339} - - component: {fileID: 1444606338} - - component: {fileID: 1444606337} - - component: {fileID: 1444606340} - - component: {fileID: 1444606341} + - component: {fileID: 1509348081} m_Layer: 0 - m_Name: PlayerCamera - m_TagString: MainCamera - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!81 &1444606337 -AudioListener: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1444606336} - m_Enabled: 1 ---- !u!20 &1444606338 -Camera: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1444606336} - m_Enabled: 1 - serializedVersion: 2 - m_ClearFlags: 1 - m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} - m_projectionMatrixMode: 1 - m_GateFitMode: 2 - m_FOVAxisMode: 0 - m_SensorSize: {x: 36, y: 24} - m_LensShift: {x: 0, y: 0} - m_FocalLength: 50 - m_NormalizedViewPortRect: - serializedVersion: 2 - x: 0 - y: 0 - width: 1 - height: 1 - near clip plane: 0.3 - far clip plane: 1000 - field of view: 65 - orthographic: 0 - orthographic size: 5 - m_Depth: -1 - m_CullingMask: - serializedVersion: 2 - m_Bits: 4294967295 - m_RenderingPath: -1 - m_TargetTexture: {fileID: 0} - m_TargetDisplay: 0 - m_TargetEye: 3 - m_HDR: 1 - m_AllowMSAA: 1 - m_AllowDynamicResolution: 0 - m_ForceIntoRT: 0 - m_OcclusionCulling: 1 - m_StereoConvergence: 10 - m_StereoSeparation: 0.022 ---- !u!4 &1444606339 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1444606336} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 1, z: -10} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 1292675909} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &1444606340 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1444606336} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3} - m_Name: - m_EditorClassIdentifier: - m_RenderShadows: 1 - m_RequiresDepthTextureOption: 2 - m_RequiresOpaqueTextureOption: 2 - m_CameraType: 0 - m_Cameras: [] - m_RendererIndex: 0 - m_VolumeLayerMask: - serializedVersion: 2 - m_Bits: 1 - m_VolumeTrigger: {fileID: 0} - m_RenderPostProcessing: 1 - m_Antialiasing: 0 - m_AntialiasingQuality: 2 - m_StopNaN: 0 - m_Dithering: 0 - m_ClearDepth: 1 - m_AllowXRRendering: 1 - m_RequiresDepthTexture: 0 - m_RequiresColorTexture: 0 - m_Version: 2 ---- !u!114 &1444606341 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1444606336} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 805caadbe4df94a40bf7ddb70bea02f6, type: 3} - m_Name: - m_EditorClassIdentifier: - _settings: {fileID: 11400000, guid: 995f378ab762cd344b7a6d108f049191, type: 2} - _inputHandler: {fileID: 1292675913} ---- !u!1 &1468685575 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1468685579} - - component: {fileID: 1468685578} - - component: {fileID: 1468685577} - m_Layer: 0 - m_Name: Graphics + m_Name: NotPlayer m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!23 &1468685577 -MeshRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1468685575} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_DynamicOccludee: 1 - 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: 1b0f58118cf7a5a4e85fda00fe3de44b, 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!33 &1468685578 -MeshFilter: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1468685575} - m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0} ---- !u!4 &1468685579 +--- !u!4 &1509348081 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1468685575} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 1, z: 0} + m_GameObject: {fileID: 1509348080} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0.56895196, y: 1.2437972, z: 4.8898325} m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 1292675909} - m_RootOrder: 0 + m_Children: + - {fileID: 472872964} + - {fileID: 349701923} + - {fileID: 1191416070} + - {fileID: 1551303228} + - {fileID: 1148358022} + - {fileID: 1908415563} + - {fileID: 470223360} + m_Father: {fileID: 0} + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1551303224 GameObject: @@ -1102,12 +675,56 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1551303224} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 2.51, y: 1, z: 13.7} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 1.941048, y: -0.24379718, z: 8.810167} m_LocalScale: {x: 2, y: 2, z: 2} m_Children: [] + m_Father: {fileID: 1509348081} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1557424584 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1557424586} + - component: {fileID: 1557424585} + m_Layer: 0 + m_Name: Loader + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1557424585 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1557424584} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 91e277ce4b818ac4fb67c516e77c391b, type: 3} + m_Name: + m_EditorClassIdentifier: + _sceneType: 3 +--- !u!4 &1557424586 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1557424584} + 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_Children: [] m_Father: {fileID: 0} - m_RootOrder: 4 + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1908415559 GameObject: @@ -1197,10 +814,75 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1908415559} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 11.2, y: 1, z: 40.56} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 10.631048, y: -0.24379718, z: 35.67017} m_LocalScale: {x: 2, y: 2, z: 2} m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 6 + m_Father: {fileID: 1509348081} + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1001 &13726837176080777 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 13726836969441544, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} + propertyPath: m_RootOrder + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 13726836969441544, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 13726836969441544, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 13726836969441544, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 13726836969441544, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 13726836969441544, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 13726836969441544, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 13726836969441544, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 13726836969441544, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 13726836969441544, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 13726836969441544, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 13726836969441781, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} + propertyPath: m_Name + value: Player + objectReference: {fileID: 0} + - target: {fileID: 13726837176080779, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} + propertyPath: _cheatBlink + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 13726837176080779, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} + propertyPath: _cheatBoost + value: 1 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} diff --git a/game/Assets/Scripts/Input/BufferedInput.cs b/game/Assets/Scripts/Input/BufferedInput.cs index 14b4d76..75141de 100644 --- a/game/Assets/Scripts/Input/BufferedInput.cs +++ b/game/Assets/Scripts/Input/BufferedInput.cs @@ -9,8 +9,8 @@ public struct BufferedInput { _bufferTime = bufferTime; _value = false; - _timeSincePress = 0f; - _timeSinceRelease = 0f; + _timeSincePress = Mathf.Infinity; + _timeSinceRelease = Mathf.Infinity; } private float _bufferTime; @@ -23,6 +23,9 @@ public struct BufferedInput if ( newValue && !_value ) { _timeSincePress = 0f; + } + else if ( !newValue && _value ) + { _timeSinceRelease = 0f; } @@ -31,12 +34,8 @@ public struct BufferedInput public void Update( float deltaTime ) { - if ( !_value ) - { - _timeSinceRelease += deltaTime; - } - _timeSincePress += deltaTime; + _timeSinceRelease += deltaTime; } public bool GetValue() @@ -44,13 +43,28 @@ public struct BufferedInput return _value || _timeSinceRelease <= _bufferTime; } - public bool GetDown() + public bool GetRawValue() { - return _value && _timeSincePress <= _bufferTime; + return _value; } - public bool GetRelease() + public bool GetDown( bool consume = true ) { - return !_value && _timeSinceRelease < _bufferTime; + bool value = _timeSincePress <= _bufferTime; + + if ( consume && value ) + _timeSincePress = Mathf.Infinity; + + return value; + } + + public bool GetRelease( bool consume = true ) + { + bool value = _timeSinceRelease <= _bufferTime; + + if ( consume && value ) + _timeSinceRelease = Mathf.Infinity; + + return value; } } diff --git a/game/Assets/Scripts/Player/PlayerController.cs b/game/Assets/Scripts/Player/PlayerController.cs index 97e4774..284e28e 100644 --- a/game/Assets/Scripts/Player/PlayerController.cs +++ b/game/Assets/Scripts/Player/PlayerController.cs @@ -1,28 +1,291 @@ -using System; -using System.Collections; -using System.Collections.Generic; +using Extensions; using UnityEngine; +using NaughtyAttributes; public class PlayerController : MonoBehaviour { + [Header("Config")] [SerializeField] + [Expandable] private PlayerMovementSettings _movementSettings; + [Header("References")] [SerializeField] private PlayerInputHandler _inputHandler; [SerializeField] - private Rigidbody _rigidbody; + private CharacterController _controller; + + [SerializeField] + private PlayerPowers _powers; + + [SerializeField] + private Transform _graphics; + + [SerializeField] + private Renderer[] _renderers; + + [Header( "Debug" )] + [SerializeField] + private Color _groundedColor; + + [SerializeField] + private Color _jumpColor; + + [SerializeField] + private Color _boostColor; + + [SerializeField] + private Color _exhaustedColor; + + [ShowNonSerializedField] + private Vector2 _surfVelocity; + + [ShowNonSerializedField] + private Vector2 _overrideDelta; + + [ShowNonSerializedField] + private float _lookAngle; + + [ShowNonSerializedField] + private float _yVelocity; + + [ShowNonSerializedField] + private bool _grounded; + + [ShowNativeProperty] + private bool Still => Mathf.Approximately( _inputHandler?.InputState.Move.Value.sqrMagnitude ?? 0f, 0f ); + + [ShowNonSerializedField] + private float _boostTime; + + [ShowNonSerializedField] + private float _fallTime; + + public bool CanJump => _grounded || _fallTime < _movementSettings.CoyoteTime; + + private const float PI = Mathf.PI; + private const float TAU = Mathf.PI * 2f; + private const float HALF_PI = Mathf.PI / 2f; + + private enum JumpState + { + None, + Jump, + Boost, + Exhausted, + COUNT, + } + + [ShowNonSerializedField] + private JumpState _jumpState; private void Start() { } + private Color GetDebugColor() + { + switch ( _jumpState ) + { + case JumpState.None: + return _groundedColor; + + case JumpState.Jump: + return _jumpColor; + + case JumpState.Boost: + return _boostColor; + + case JumpState.Exhausted: + return _exhaustedColor; + } + + return Color.red; + } + + private float normaliseAngle( float angle ) + { + while ( angle > PI ) + { + angle -= TAU; + } + + while ( angle < -PI ) + { + angle += TAU; + } + + return angle; + } + + private void Land() + { + _powers.Blink.Reset(); + _powers.Boost.Reset(); + } + + private void UpdateLook( float dt ) + { + if ( _surfVelocity.sqrMagnitude > 0.01f ) + { + float targetAngle = -Vector2.SignedAngle( Vector2.up, _surfVelocity.normalized ) * Mathf.Deg2Rad; + float delta = targetAngle - _lookAngle; + float ls = _movementSettings.LookSpeed * dt; + + _lookAngle += Mathf.Clamp( normaliseAngle(delta), -ls, ls ); + _lookAngle = normaliseAngle( _lookAngle ); + } + } + + private void UpdateBlink( float dt ) + { + if ( _powers.Blink.CanConsume && _inputHandler.InputState.Blink.GetDown() ) + { + _powers.Blink.Consume(); + Vector2 blinkDirection = Vector2.up.Rotate( -_lookAngle ); + _overrideDelta += blinkDirection * _movementSettings.BlinkDistance; + _surfVelocity += blinkDirection * _movementSettings.BlinkVelocity; + } + } + + private void UpdateJump(float dt) + { + _fallTime = _grounded ? 0f : (_fallTime + dt); + + switch ( _jumpState ) + { + case JumpState.None: + if ( CanJump ) + { + if ( _inputHandler.InputState.Jump.GetDown() ) + { + _grounded = false; + _jumpState = JumpState.Jump; + _yVelocity = Mathf.Sqrt( 2f * _movementSettings.JumpHeight * _movementSettings.UpGravity ); + + // always make sure we can blink once per jump + _powers.Blink.Reset(); + } + } + else + { + _jumpState = JumpState.Jump; + } + break; + + case JumpState.Jump: + if ( _powers.Boost.CanConsume && _inputHandler.InputState.Jump.GetDown( consume: false ) ) + { + _powers.Boost.Consume(); + _boostTime = 0f; + _jumpState = JumpState.Boost; + if ( _yVelocity < _movementSettings.MinBoostVelocity ) + { + _yVelocity = _movementSettings.MinBoostVelocity; + } + } + + break; + + case JumpState.Boost: + if ( _inputHandler.InputState.Jump.GetRawValue() ) + { + _yVelocity += _movementSettings.BoostForce * dt; + _boostTime += dt; + if ( _boostTime > _movementSettings.BoostTime ) + { + _jumpState = JumpState.Exhausted; + } + } + break; + + default: + break; + } + } + + private void UpdateGravity( float dt ) + { + if ( _grounded ) + { + _yVelocity = _movementSettings.GroundedYVelocity; + _jumpState = JumpState.None; + } + else + { + if ( _yVelocity > 0f && _jumpState == JumpState.Jump ) + { + _yVelocity -= ( _movementSettings.UpGravity * dt ); + } + else + { + _yVelocity -= ( _movementSettings.DownGravity * dt ); + } + } + } + + private void UpdateDrag( float dt ) + { + Vector2 drag = -_surfVelocity; + float coefficient + = _grounded + ? ( Still + ? _movementSettings.StillDragCoefficient + : _movementSettings.DragCoefficient ) + : ( _jumpState == JumpState.Boost + ? _movementSettings.BoostDragCoefficient + : _movementSettings.AirDragCoefficient ); + + _surfVelocity += drag * (dt * coefficient); + } + + private void UpdateMovement( float dt ) + { + Vector2 moveVector = _inputHandler.InputState.Move.Value; + _surfVelocity += moveVector * (_movementSettings.BaseMovementForce * dt); + } + + private void UpdateDebug() + { + Color debugColor = GetDebugColor(); + for ( int i = 0; i < _renderers.Length; ++i ) + { + _renderers[ i ].material.color = debugColor; + } + } + private void FixedUpdate() { - Vector2 moveVector2 = _inputHandler.InputState.Move.Value; - Vector3 moveVector = new Vector3( moveVector2.x, 0f, moveVector2.y ); + float dt = Time.fixedDeltaTime; + + _overrideDelta = Vector2.zero; + + if ( !_grounded && _controller.isGrounded ) + { + Land(); + } - _rigidbody.velocity = moveVector * _movementSettings.BaseMovementSpeed; + _grounded = _controller.isGrounded; + + _powers.UpdatePowers( dt, _grounded ); + + UpdateJump( dt ); + UpdateLook( dt ); + UpdateBlink( dt ); + UpdateGravity( dt ); + UpdateDrag( dt ); + UpdateMovement( dt ); + UpdateDebug(); + + _controller.Move( + new Vector3( + _surfVelocity.x * dt + _overrideDelta.x, + _yVelocity * dt, + _surfVelocity.y * dt + _overrideDelta.y + ) + ); + + _graphics.rotation = Quaternion.Euler( 0f, _lookAngle * Mathf.Rad2Deg, 0f ); } } \ No newline at end of file diff --git a/game/Assets/Scripts/Player/PlayerInputHandler.cs b/game/Assets/Scripts/Player/PlayerInputHandler.cs index ef4997d..ae816c5 100644 --- a/game/Assets/Scripts/Player/PlayerInputHandler.cs +++ b/game/Assets/Scripts/Player/PlayerInputHandler.cs @@ -9,13 +9,30 @@ public class PlayerInputHandler : MonoBehaviour [SerializeField] private PlayerInputSettings _inputSettings; - public struct PlayerInputState + public class PlayerInputState { public BufferedInput Jump; + public BufferedInput Blink; public BufferedInput Use; public CameraRelativeInput Move; public Vector2 Look; public float MoveRotation; + + public PlayerInputState( float jumpBuffer, float blinkBuffer, float useBuffer ) + { + Jump = new BufferedInput( jumpBuffer ); + Blink = new BufferedInput( blinkBuffer ); + Use = new BufferedInput( useBuffer ); + Move = new CameraRelativeInput(); + Look = Vector2.zero; + } + + public void Update( float deltaTime ) + { + Jump.Update(deltaTime); + Blink.Update(deltaTime); + Use.Update(deltaTime); + } } public PlayerInputState InputState => _state; @@ -24,20 +41,16 @@ public class PlayerInputHandler : MonoBehaviour private void Awake() { - _state = new PlayerInputState(); - - _state.Jump = new BufferedInput( _inputSettings.JumpBufferTime ); - _state.Use = new BufferedInput( _inputSettings.UseBufferTime ); - _state.Move = new CameraRelativeInput(); - _state.Look = Vector2.zero; + _state = new PlayerInputState( + _inputSettings.JumpBufferTime, + _inputSettings.BlinkBufferTime, + _inputSettings.UseBufferTime + ); } private void FixedUpdate() { - float deltaTime = Time.fixedDeltaTime; - - _state.Jump.Update( deltaTime ); - _state.Use.Update( deltaTime ); + _state.Update( Time.fixedDeltaTime ); } public void SetCameraRotation( float angle ) @@ -49,9 +62,12 @@ public class PlayerInputHandler : MonoBehaviour public void Move( InputAction.CallbackContext context ) => _state.Move.SetValue( context.ReadValue() ); + public void Blink( InputAction.CallbackContext context ) + => _state.Blink.Set( context.ReadValueAsButton() ); + public void Jump( InputAction.CallbackContext context ) - => _state.Jump.Set( context.ReadValue() > 0.5f ); + => _state.Jump.Set( context.ReadValueAsButton() ); public void Use( InputAction.CallbackContext context ) - => _state.Use.Set( context.ReadValue() > 0.5f ); + => _state.Use.Set( context.ReadValueAsButton() ); } \ No newline at end of file diff --git a/game/Assets/Scripts/Player/PlayerInputSettings.cs b/game/Assets/Scripts/Player/PlayerInputSettings.cs index 6fc9b0c..68f8415 100644 --- a/game/Assets/Scripts/Player/PlayerInputSettings.cs +++ b/game/Assets/Scripts/Player/PlayerInputSettings.cs @@ -1,10 +1,20 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -[CreateAssetMenu(fileName = "PlayerInputSettings.asset", menuName = "KernelPanic/Player/InputSettings")] -public class PlayerInputSettings : ScriptableObject -{ - public float JumpBufferTime; - public float UseBufferTime; -} +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +[CreateAssetMenu(fileName = "PlayerInputSettings.asset", menuName = "KernelPanic/Player/InputSettings")] +public class PlayerInputSettings : ScriptableObject +{ + public float JumpBufferTime => _jumpBufferTime; + public float BlinkBufferTime => _blinkBufferTime; + public float UseBufferTime => _useBufferTime; + + [SerializeField] + private float _jumpBufferTime; + + [SerializeField] + private float _blinkBufferTime; + + [SerializeField] + private float _useBufferTime; +} diff --git a/game/Assets/Scripts/Player/PlayerMovementSettings.cs b/game/Assets/Scripts/Player/PlayerMovementSettings.cs index 9b82316..5f701ad 100644 --- a/game/Assets/Scripts/Player/PlayerMovementSettings.cs +++ b/game/Assets/Scripts/Player/PlayerMovementSettings.cs @@ -1,9 +1,71 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +using UnityEngine.Serialization; [CreateAssetMenu(fileName = "PlayerMovementSettings.asset", menuName = "KernelPanic/Player/MovementSettings")] public class PlayerMovementSettings : ScriptableObject { - public float BaseMovementSpeed; + public float UpGravity => _upGravity; + public float DownGravity => _downGravity; + public float GroundedYVelocity => _groundedYVelocity; + public float BaseMovementForce => _baseMovementForce; + public float JumpHeight => _jumpHeight; + public float CoyoteTime => _coyoteTime; + public float BoostForce => _boostForce; + public float BoostTime => _boostTime; + public float BlinkDistance => _blinkDistance; + public float BlinkVelocity => _blinkVelocity; + public float MinBoostVelocity => _minBoostVelocity; + public float DragCoefficient => _dragCoefficient; + public float BoostDragCoefficient => _boostDragCoefficient; + public float AirDragCoefficient => _airDragCoefficient; + public float StillDragCoefficient => _stillDragCoefficient; + public float LookSpeed => _lookSpeed; + + [Header( "Look" )] + [SerializeField] + private float _lookSpeed; + + [Header("Gravity")] + [SerializeField] + private float _upGravity; + [SerializeField] + private float _downGravity; + [SerializeField] + private float _groundedYVelocity; + + [Header("Movement")] + [SerializeField] + private float _baseMovementForce; + + [Header("Jump")] + [SerializeField] + private float _jumpHeight; + [SerializeField] + private float _coyoteTime; + + [Header("Boost")] + [SerializeField] + private float _boostForce; + [SerializeField] + private float _boostTime; + [SerializeField] + private float _minBoostVelocity; + + [Header( "Blink" )] + [SerializeField] + private float _blinkDistance; + [SerializeField] + private float _blinkVelocity; + + [Header("Drag")] + [SerializeField] + private float _dragCoefficient; + [SerializeField] + private float _boostDragCoefficient; + [SerializeField] + private float _airDragCoefficient; + [SerializeField] + private float _stillDragCoefficient; } diff --git a/game/Assets/Scripts/Player/PlayerPower.cs b/game/Assets/Scripts/Player/PlayerPower.cs new file mode 100644 index 0000000..92fe77f --- /dev/null +++ b/game/Assets/Scripts/Player/PlayerPower.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Events; + +[CreateAssetMenu(menuName = "KernelPanic/Player/Power", fileName = "PlayerPower.asset")] +public class PlayerPower : ScriptableObject +{ + [SerializeField] + private bool _regenerateOnGround; + + [SerializeField] + private bool _regenerateInAir; + + [SerializeField] + private float _regenerateTime; + + private bool _unlocked; + private bool _cheated; + private bool _consumed; + + private float _timeSinceConsume; + + private UnityEvent _onUnlock = new UnityEvent(); + public UnityEvent OnUnlock => _onUnlock; + + public void UpdatePower( float deltaTime, bool cheat, bool grounded) + { + _cheated = cheat; + + bool regenerate = grounded ? _regenerateOnGround : _regenerateInAir; + + if ( _consumed && regenerate ) + { + _timeSinceConsume += deltaTime; + + if ( _timeSinceConsume > _regenerateTime ) + { + this.Reset(); + } + } + } + + public bool IsUnlocked => _unlocked || _cheated; + public bool CanConsume => IsUnlocked && !_consumed; + + public void Consume() + => _consumed = true; + + public void Reset() + { + _consumed = false; + _timeSinceConsume = 0f; + } + + public void Unlock() + { + if ( !_unlocked ) + { + _onUnlock.Invoke(); + _unlocked = true; + } + } + + private void Awake() + { + _unlocked = false; + _cheated = false; + } +} diff --git a/game/Assets/Scripts/Player/PlayerPower.cs.meta b/game/Assets/Scripts/Player/PlayerPower.cs.meta new file mode 100644 index 0000000..7071eeb --- /dev/null +++ b/game/Assets/Scripts/Player/PlayerPower.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 24d28ac60e22b5547b2beb8679625039 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/game/Assets/Scripts/Player/PlayerPowers.cs b/game/Assets/Scripts/Player/PlayerPowers.cs new file mode 100644 index 0000000..8ddb7fa --- /dev/null +++ b/game/Assets/Scripts/Player/PlayerPowers.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PlayerPowers : MonoBehaviour +{ + [Header( "Cheats" )] + [SerializeField] + private bool _cheatBlink; + + [SerializeField] + private bool _cheatBoost; + + [Header( "References" )] + [SerializeField] + private PlayerPower _blink; + + [SerializeField] + private PlayerPower _boost; + + public PlayerPower Blink => _blink; + public PlayerPower Boost => _boost; + + public void UpdatePowers( float dt, bool grounded ) + { + _blink.UpdatePower( dt, _cheatBlink, grounded ); + _boost.UpdatePower( dt, _cheatBoost, grounded ); + } +} \ No newline at end of file diff --git a/game/Assets/Scripts/Player/PlayerPowers.cs.meta b/game/Assets/Scripts/Player/PlayerPowers.cs.meta new file mode 100644 index 0000000..f27291e --- /dev/null +++ b/game/Assets/Scripts/Player/PlayerPowers.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0e73a47345d899f4ca1e5e08683c2b82 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/game/Assets/Scripts/Util/MathsExtensions.cs b/game/Assets/Scripts/Util/MathsExtensions.cs new file mode 100644 index 0000000..a129c7e --- /dev/null +++ b/game/Assets/Scripts/Util/MathsExtensions.cs @@ -0,0 +1,21 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Extensions +{ + public static class MathsExtensions + { + public static Vector2 Rotate( this Vector2 v, float angle ) + { + float sa = Mathf.Sin( angle ); + float ca = Mathf.Cos( angle ); + + return new Vector2 + { + x = ca * v.x - sa * v.y, + y = sa * v.x + ca * v.y + }; + } + } +} diff --git a/game/Assets/Scripts/Util/MathsExtensions.cs.meta b/game/Assets/Scripts/Util/MathsExtensions.cs.meta new file mode 100644 index 0000000..f3500a7 --- /dev/null +++ b/game/Assets/Scripts/Util/MathsExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4e4dcb81b531095448f1837f3992c155 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/game/Assets/Settings/Input/PlayerControls.inputactions b/game/Assets/Settings/Input/PlayerControls.inputactions index 8c10c35..ffae4f3 100644 --- a/game/Assets/Settings/Input/PlayerControls.inputactions +++ b/game/Assets/Settings/Input/PlayerControls.inputactions @@ -10,7 +10,7 @@ "type": "Value", "id": "5c440996-60ec-4084-9223-75d39638108a", "expectedControlType": "Vector2", - "processors": "", + "processors": "StickDeadzone", "interactions": "" }, { @@ -36,6 +36,14 @@ "expectedControlType": "DiscreteButton", "processors": "", "interactions": "" + }, + { + "name": "Blink", + "type": "Value", + "id": "0eb55067-1328-4b0a-9494-b427befe049a", + "expectedControlType": "Button", + "processors": "", + "interactions": "" } ], "bindings": [ @@ -170,6 +178,28 @@ "action": "Use", "isComposite": false, "isPartOfComposite": false + }, + { + "name": "", + "id": "a6650120-343f-4b39-85d4-0b9ea96a2f54", + "path": "/rightShoulder", + "interactions": "", + "processors": "", + "groups": "Gamepad", + "action": "Blink", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "fc2a21f0-c455-4dc7-aef5-679229ab7cdc", + "path": "/shift", + "interactions": "", + "processors": "", + "groups": "PCMR", + "action": "Blink", + "isComposite": false, + "isPartOfComposite": false } ] } diff --git a/game/Assets/Settings/Player/PlayerInputSettings.asset b/game/Assets/Settings/Player/PlayerInputSettings.asset index 471f168..6ae14f2 100644 --- a/game/Assets/Settings/Player/PlayerInputSettings.asset +++ b/game/Assets/Settings/Player/PlayerInputSettings.asset @@ -12,5 +12,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5757917e8ea41b845b309988926a0617, type: 3} m_Name: PlayerInputSettings m_EditorClassIdentifier: - JumpBufferTime: 0 - UseBufferTime: 0 + _jumpBufferTime: 0.1 + _blinkBufferTime: 0.1 + _useBufferTime: 0.1 diff --git a/game/Assets/Settings/Player/PlayerMovementSettings.asset b/game/Assets/Settings/Player/PlayerMovementSettings.asset index 420b743..f59da2b 100644 --- a/game/Assets/Settings/Player/PlayerMovementSettings.asset +++ b/game/Assets/Settings/Player/PlayerMovementSettings.asset @@ -12,4 +12,19 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f1cbb1d5d2a7715478647c26d4e71482, type: 3} m_Name: PlayerMovementSettings m_EditorClassIdentifier: - BaseMovementSpeed: 10 + _lookSpeed: 20 + _upGravity: 15 + _downGravity: 40 + _groundedYVelocity: -1 + _baseMovementForce: 150 + _jumpHeight: 1.5 + _coyoteTime: 0.15 + _boostForce: 45 + _boostTime: 0.75 + _minBoostVelocity: 0 + _blinkDistance: 10 + _blinkVelocity: 10 + _dragCoefficient: 14 + _boostDragCoefficient: 30 + _airDragCoefficient: 20 + _stillDragCoefficient: 20 diff --git a/game/Assets/Settings/Player/Powers.meta b/game/Assets/Settings/Player/Powers.meta new file mode 100644 index 0000000..035976b --- /dev/null +++ b/game/Assets/Settings/Player/Powers.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e4c7efa4e43957d4dbc612873b2e08f5 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/game/Assets/Settings/Player/Powers/Blink.asset b/game/Assets/Settings/Player/Powers/Blink.asset new file mode 100644 index 0000000..0f8359e --- /dev/null +++ b/game/Assets/Settings/Player/Powers/Blink.asset @@ -0,0 +1,17 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 24d28ac60e22b5547b2beb8679625039, type: 3} + m_Name: Blink + m_EditorClassIdentifier: + _regenerateOnGround: 1 + _regenerateInAir: 0 + _regenerateTime: 2 diff --git a/game/Assets/Settings/Player/Powers/Blink.asset.meta b/game/Assets/Settings/Player/Powers/Blink.asset.meta new file mode 100644 index 0000000..a72c433 --- /dev/null +++ b/game/Assets/Settings/Player/Powers/Blink.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b47ea197a7cc2ed4eb15271cef672997 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/game/Assets/Settings/Player/Powers/Boost.asset b/game/Assets/Settings/Player/Powers/Boost.asset new file mode 100644 index 0000000..0d97a68 --- /dev/null +++ b/game/Assets/Settings/Player/Powers/Boost.asset @@ -0,0 +1,15 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 24d28ac60e22b5547b2beb8679625039, type: 3} + m_Name: Boost + m_EditorClassIdentifier: + _name: diff --git a/game/Assets/Settings/Player/Powers/Boost.asset.meta b/game/Assets/Settings/Player/Powers/Boost.asset.meta new file mode 100644 index 0000000..9a45f72 --- /dev/null +++ b/game/Assets/Settings/Player/Powers/Boost.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d5ed942937d8cca478f3ec97f6b9c8a2 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/game/ProjectSettings/ProjectSettings.asset b/game/ProjectSettings/ProjectSettings.asset index a9070a8..ceb220e 100644 --- a/game/ProjectSettings/ProjectSettings.asset +++ b/game/ProjectSettings/ProjectSettings.asset @@ -128,7 +128,8 @@ PlayerSettings: 16:9: 1 Others: 1 bundleVersion: 0.1 - preloadedAssets: [] + preloadedAssets: + - {fileID: 11400000, guid: 87faf39b6f22e524984c1680a88045ac, type: 2} metroInputSource: 0 wsaTransparentSwapchain: 0 m_HolographicPauseOnTrackingLoss: 1