From bbfb583e3cf31cc8aa8c8e9adb3bf29e21928331 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 14 Jul 2025 14:22:50 -0400 Subject: [PATCH] added: tools for changing camera settings, and camera settings processor --- Assets/Player/Input/PlayerInputs.inputactions | 70 ++---- .../PartialEditor/PropertyDrawerFactory.cs | 6 +- Assets/Scenes/SampleScene.unity | 26 ++- .../Core/Graph Tasks/ChangeCameraSettings.cs | 217 +++++++++++------- .../Scripts/Player/CameraSettingsProcessor.cs | 128 +++++++++++ .../Player/CameraSettingsProcessor.cs.meta | 2 + Assets/Scripts/Player/PlayerControls.cs | 15 +- 7 files changed, 307 insertions(+), 157 deletions(-) create mode 100644 Assets/Scripts/Player/CameraSettingsProcessor.cs create mode 100644 Assets/Scripts/Player/CameraSettingsProcessor.cs.meta diff --git a/Assets/Player/Input/PlayerInputs.inputactions b/Assets/Player/Input/PlayerInputs.inputactions index d7d7365..683f295 100644 --- a/Assets/Player/Input/PlayerInputs.inputactions +++ b/Assets/Player/Input/PlayerInputs.inputactions @@ -62,7 +62,7 @@ { "name": "Grapple", "type": "Button", - "id": "00393a1c-cfdb-46f8-8e02-552382b53236", + "id": "e0a48394-3128-4596-9b75-5dd3e82d3315", "expectedControlType": "", "processors": "", "interactions": "", @@ -169,17 +169,6 @@ "isComposite": false, "isPartOfComposite": false }, - { - "name": "", - "id": "0aec47c4-b519-4001-9408-a49abe218bd8", - "path": "", - "interactions": "", - "processors": "", - "groups": "", - "action": "Lock-On", - "isComposite": false, - "isPartOfComposite": false - }, { "name": "", "id": "c9d67b81-b640-4a64-9b31-f92c927c8345", @@ -191,50 +180,6 @@ "isComposite": false, "isPartOfComposite": false }, - { - "name": "", - "id": "89e90b8f-c830-4d10-9046-c1db1ef970d0", - "path": "", - "interactions": "", - "processors": "", - "groups": "", - "action": "Cancel Lock-On", - "isComposite": false, - "isPartOfComposite": false - }, - { - "name": "One Modifier", - "id": "cd93e290-6f16-49c1-af36-9d3eaedeb8a2", - "path": "OneModifier", - "interactions": "", - "processors": "", - "groups": "", - "action": "Cancel Lock-On", - "isComposite": true, - "isPartOfComposite": false - }, - { - "name": "modifier", - "id": "8713a052-f2c4-439a-acae-f845a5654819", - "path": "", - "interactions": "", - "processors": "", - "groups": "", - "action": "Cancel Lock-On", - "isComposite": false, - "isPartOfComposite": true - }, - { - "name": "binding", - "id": "013863ac-050d-4d7f-a36c-bce06827ad17", - "path": "", - "interactions": "", - "processors": "", - "groups": "", - "action": "Cancel Lock-On", - "isComposite": false, - "isPartOfComposite": true - }, { "name": "", "id": "84c3f849-8d7f-40ea-8c6c-4b5af0d9addd", @@ -248,7 +193,18 @@ }, { "name": "", - "id": "3c93b098-1bd2-42c6-90d6-3eea7694acd0", + "id": "88d7eb5e-771c-4c79-a692-521032759ba7", + "path": "", + "interactions": "", + "processors": "", + "groups": "", + "action": "Grapple", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "0c543052-3c80-432e-a34b-8fcb9267028a", "path": "/rightTrigger", "interactions": "", "processors": "", diff --git a/Assets/Plugins/ParadoxNotion/CanvasCore/Common/Design/PartialEditor/PropertyDrawerFactory.cs b/Assets/Plugins/ParadoxNotion/CanvasCore/Common/Design/PartialEditor/PropertyDrawerFactory.cs index 15b1ec6..0b79e06 100644 --- a/Assets/Plugins/ParadoxNotion/CanvasCore/Common/Design/PartialEditor/PropertyDrawerFactory.cs +++ b/Assets/Plugins/ParadoxNotion/CanvasCore/Common/Design/PartialEditor/PropertyDrawerFactory.cs @@ -152,7 +152,7 @@ namespace ParadoxNotion.Design } ///Override to implement GUI. Return the modified instance at the end. - abstract public T OnGUI(GUIContent content, T instance); + abstract public T OnGUI(GUIContent content, T _instance); } ///The default object drawer implementation able to inspect most types @@ -165,8 +165,8 @@ namespace ParadoxNotion.Design this.objectType = objectType; } - public override object OnGUI(GUIContent content, object instance) { - return EditorUtils.DrawEditorFieldDirect(content, instance, objectType, info); + public override object OnGUI(GUIContent content, object _instance) { + return EditorUtils.DrawEditorFieldDirect(content, _instance, objectType, info); } } diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index b2c5e96..da1a2f7 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -2644,7 +2644,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 330585543} serializedVersion: 2 - m_LocalRotation: {x: 0.11558351, y: 0.00000003563248, z: -0.000000004146316, w: 0.99329776} + m_LocalRotation: {x: 0.039987642, y: -0.0000000031281908, z: 1.251891e-10, w: 0.99920017} m_LocalPosition: {x: 1.503913, y: 2.0657892, z: -6.8609486} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 @@ -2840,6 +2840,7 @@ GameObject: - component: {fileID: 402424911} - component: {fileID: 402424910} - component: {fileID: 402424908} + - component: {fileID: 402424912} m_Layer: 0 m_Name: Cinemachine m_TagString: Untagged @@ -2898,7 +2899,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 402424904} serializedVersion: 2 - m_LocalRotation: {x: 0.115583494, y: 0.000000035632475, z: -0.000000004146315, w: 0.99329776} + m_LocalRotation: {x: 0.039987642, y: -0.0000000031281908, z: 1.2518941e-10, w: 0.99920017} m_LocalPosition: {x: 1.503913, y: 2.0657892, z: -6.8609486} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 @@ -3069,13 +3070,25 @@ MonoBehaviour: Size: {x: 0.8, y: 0.8} Offset: {x: 0, y: 0} CenterOnActivate: 1 - TargetOffset: {x: 0, y: 0, z: 0} + TargetOffset: {x: 0, y: 1, z: 0} Damping: {x: 0.5, y: 0.5} Lookahead: Enabled: 0 Time: 0 Smoothing: 0 IgnoreY: 0 +--- !u!114 &402424912 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 402424904} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c032a18b0b0c1da4092bfc365c6e4aad, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &410087039 GameObject: m_ObjectHideFlags: 0 @@ -6716,7 +6729,9 @@ MonoBehaviour: Climb Jump","_position":{"x":1065.998,"y":-269.9991},"$type":"NodeCanvas.StateMachines.SuperActionState","$id":"2"},{"_onEnterList":{"executionMode":1,"actions":[{"jumpStrength":{},"airMoveDirection":{},"standStillJumpStrength":{},"jumpPower":{},"currentVelocityInheritence":{},"directionalForce":{},"directionalForceStrength":{},"$type":"NodeCanvas.Tasks.Actions.AddJump"},{"valueA":{"_name":"gravityPower","_targetVariableID":"2221dc20-d9b3-4781-bd23-0b2038a7ff5e"},"valueB":{},"$type":"NodeCanvas.Tasks.Actions.SetFloat"}]},"_onUpdateList":{"executionMode":1,"actions":[]},"_onExitList":{"executionMode":1,"actions":[]},"foldEnter":true,"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_name":"Wall Jump","_position":{"x":868.4374,"y":-418.9596},"$type":"NodeCanvas.StateMachines.SuperActionState","$id":"3"},{"_onEnterList":{"executionMode":1,"actions":[{"jumpStrength":{"_value":12.0},"airMoveDirection":{"_name":"airMoveDirection","_targetVariableID":"8f5f926f-618d-4bcb-87eb-0bcd02e405a2"},"standStillJumpStrength":{"_value":1.0},"jumpPower":{"_name":"jumpPower","_targetVariableID":"9a82efee-e317-423c-ad6e-5ef7e6145396"},"currentVelocityInheritence":{"_value":1.0},"directionalForce":{},"directionalForceStrength":{},"$type":"NodeCanvas.Tasks.Actions.AddJump"},{"valueA":{"_name":"gravityPower","_targetVariableID":"2221dc20-d9b3-4781-bd23-0b2038a7ff5e"},"valueB":{},"$type":"NodeCanvas.Tasks.Actions.SetFloat"}]},"_onUpdateList":{"executionMode":1,"actions":[]},"_onExitList":{"executionMode":1,"actions":[]},"foldEnter":true,"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_name":"Standard Jump","_position":{"x":831.2836,"y":45.40904},"$type":"NodeCanvas.StateMachines.SuperActionState","$id":"4"},{"_onEnterList":{"executionMode":1,"actions":[]},"_onUpdateList":{"executionMode":1,"actions":[{"airMoveDirection":{"_name":"airMoveDirection","_targetVariableID":"8f5f926f-618d-4bcb-87eb-0bcd02e405a2"},"groundMoveDirection":{"_name":"groundMoveDirection","_targetVariableID":"765d24b4-452d-4531-9fce-6cef7ba39634"},"$type":"NodeCanvas.Tasks.Actions.CalculateAirMovement"}]},"_onExitList":{"executionMode":1,"actions":[]},"foldEnter":true,"foldUpdate":true,"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_name":"Airborn","_position":{"x":213.7761,"y":-7.08618},"$type":"NodeCanvas.StateMachines.SuperActionState","$id":"5"},{"_onEnterList":{"executionMode":1,"actions":[{"jumpStrength":{"_value":10.0},"airMoveDirection":{"_name":"airMoveDirection","_targetVariableID":"8f5f926f-618d-4bcb-87eb-0bcd02e405a2"},"standStillJumpStrength":{},"jumpPower":{"_name":"jumpPower","_targetVariableID":"9a82efee-e317-423c-ad6e-5ef7e6145396"},"currentVelocityInheritence":{"_value":0.3},"directionalForce":{"_value":{"x":1.0,"z":1.0}},"directionalForceStrength":{"_value":10.0},"$type":"NodeCanvas.Tasks.Actions.AddJump"},{"valueA":{"_name":"gravityPower","_targetVariableID":"2221dc20-d9b3-4781-bd23-0b2038a7ff5e"},"valueB":{},"$type":"NodeCanvas.Tasks.Actions.SetFloat"}]},"_onUpdateList":{"executionMode":1,"actions":[]},"_onExitList":{"executionMode":1,"actions":[]},"foldEnter":true,"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_name":"Wall - Jump","_position":{"x":328.7507,"y":-415.5261},"$type":"NodeCanvas.StateMachines.SuperActionState","$id":"6"},{"_actionList":{"executionMode":1,"actions":[{"cinemachine":{"_value":1},"orbitFollowTop":{"label":"Top","changeHeight":1,"height":2.0,"changeRadius":1,"radius":2.0},"orbitFollowCenter":{"label":"Center","changeHeight":1,"height":1.5,"changeRadius":1,"radius":2.4},"orbitFollowBottom":{"label":"Bottom","changeHeight":1,"height":0.7,"changeRadius":1,"radius":2.0},"$type":"NodeCanvas.Tasks.Actions.ChangeCameraSettings"}]},"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_position":{"x":790.0,"y":392.0},"$type":"NodeCanvas.StateMachines.ActionState","$id":"7"},{"_actionList":{"executionMode":1,"actions":[{"cinemachine":{"_value":1},"orbitFollowTop":{"label":"Top","changeHeight":2,"changeRadius":2},"orbitFollowCenter":{"changeHeight":2,"changeRadius":2},"orbitFollowBottom":{"changeHeight":2,"changeRadius":2},"$type":"NodeCanvas.Tasks.Actions.ChangeCameraSettings"}]},"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_position":{"x":583.0,"y":512.0},"$type":"NodeCanvas.StateMachines.ActionState","$id":"8"},{"_subFSM":{"_value":2},"_variablesMap":[{"_targetSubGraphVariableID":"16ae5ce4-097a-4c21-94a5-2c5d9ce73eb6","_canRead":true,"_canWrite":true,"_type":"UnityEngine.Vector3","_name":"groundMoveDirection","_targetVariableID":"765d24b4-452d-4531-9fce-6cef7ba39634"},{"_targetSubGraphVariableID":"d888730f-97df-4288-bb99-1f6c8a34a7c5","_canRead":true,"_canWrite":true,"_type":"System.Single","_name":"rotationSpeed","_targetVariableID":"3a7d1c7c-8fb6-4a99-b25a-b434b62d4611"}],"_position":{"x":-50.62204,"y":454.3138},"$type":"NodeCanvas.StateMachines.ConcurrentSubFSM"},{"_conditionList":{"conditions":[{"_invert":true,"$type":"NodeCanvas.Tasks.Conditions.DebugCondition"}]},"_actionList":{"executionMode":1,"actions":[{"groundMoveDirection":{"_name":"groundMoveDirection","_targetVariableID":"765d24b4-452d-4531-9fce-6cef7ba39634"},"airMoveDirection":{"_name":"airMoveDirection","_targetVariableID":"8f5f926f-618d-4bcb-87eb-0bcd02e405a2"},"gravityAcceleration":{"_value":1.0},"gravityMax":{"_value":8.0},"jumpPower":{"_name":"jumpPower","_targetVariableID":"9a82efee-e317-423c-ad6e-5ef7e6145396"},"jumpPowerDecay":{"_value":2.0},"playerFacingDirection":1,"rotationSpeed":{"_name":"rotationSpeed","_targetVariableID":"3a7d1c7c-8fb6-4a99-b25a-b434b62d4611"},"rotationSmoothing":{"_value":1.0},"gravityPower":{"_name":"gravityPower","_targetVariableID":"2221dc20-d9b3-4781-bd23-0b2038a7ff5e"},"$type":"NodeCanvas.Tasks.Actions.ProcessMovement"}]},"_position":{"x":-53.13062,"y":301.5233},"$type":"NodeCanvas.StateMachines.OnFSMEnter"}],"connections":[{"_condition":{"valueA":{"_name":"isGrounded","_targetVariableID":"619300a4-be8b-4ad4-ba2a-978468094ba2"},"valueB":{},"$type":"NodeCanvas.Tasks.Conditions.CheckBoolean"},"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"1"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"actionName":{"_value":"Jump"},"actionValue":{},"$type":"NodeCanvas.Tasks.Conditions.CheckInput"},"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"4"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"actionName":{"_value":"Grapple"},"actionValue":{},"$type":"NodeCanvas.Tasks.Conditions.CheckInput"},"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"7"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"conditions":[{"eventName":{"_value":"ForwardRay"},"value":{"_value":true},"$type":"NodeCanvas.Tasks.Conditions.CheckEventValue`1[[System.Boolean, + Jump","_position":{"x":328.7507,"y":-415.5261},"$type":"NodeCanvas.StateMachines.SuperActionState","$id":"6"},{"_actionList":{"executionMode":1,"actions":[{"orbitFollowTop":{"label":"Top","changeHeight":1,"height":2.0,"changeRadius":1,"radius":2.0},"orbitFollowCenter":{"label":"Center","changeHeight":1,"height":1.5,"changeRadius":1,"radius":2.4},"orbitFollowBottom":{"label":"Bottom","changeHeight":1,"height":0.7,"changeRadius":1,"radius":2.0},"screenPosition":{"label":"Screen + Position","newValue":{"x":-0.25},"changeX":1},"$type":"NodeCanvas.Tasks.Actions.ChangeCameraSettings"}]},"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_position":{"x":793.0,"y":391.0},"$type":"NodeCanvas.StateMachines.ActionState","$id":"7"},{"_actionList":{"executionMode":1,"actions":[{"orbitFollowTop":{"label":"Top","changeHeight":2,"changeRadius":2},"orbitFollowCenter":{"changeHeight":2,"changeRadius":2},"orbitFollowBottom":{"changeHeight":2,"changeRadius":2},"screenPosition":{"label":"Screen + Position","changeX":2,"changeY":2},"$type":"NodeCanvas.Tasks.Actions.ChangeCameraSettings"}]},"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_position":{"x":583.0,"y":512.0},"$type":"NodeCanvas.StateMachines.ActionState","$id":"8"},{"_subFSM":{"_value":1},"_variablesMap":[{"_targetSubGraphVariableID":"16ae5ce4-097a-4c21-94a5-2c5d9ce73eb6","_canRead":true,"_canWrite":true,"_type":"UnityEngine.Vector3","_name":"groundMoveDirection","_targetVariableID":"765d24b4-452d-4531-9fce-6cef7ba39634"},{"_targetSubGraphVariableID":"d888730f-97df-4288-bb99-1f6c8a34a7c5","_canRead":true,"_canWrite":true,"_type":"System.Single","_name":"rotationSpeed","_targetVariableID":"3a7d1c7c-8fb6-4a99-b25a-b434b62d4611"}],"_position":{"x":-50.62204,"y":454.3138},"$type":"NodeCanvas.StateMachines.ConcurrentSubFSM"},{"_conditionList":{"conditions":[{"_invert":true,"$type":"NodeCanvas.Tasks.Conditions.DebugCondition"}]},"_actionList":{"executionMode":1,"actions":[{"groundMoveDirection":{"_name":"groundMoveDirection","_targetVariableID":"765d24b4-452d-4531-9fce-6cef7ba39634"},"airMoveDirection":{"_name":"airMoveDirection","_targetVariableID":"8f5f926f-618d-4bcb-87eb-0bcd02e405a2"},"gravityAcceleration":{"_value":1.0},"gravityMax":{"_value":8.0},"jumpPower":{"_name":"jumpPower","_targetVariableID":"9a82efee-e317-423c-ad6e-5ef7e6145396"},"jumpPowerDecay":{"_value":2.0},"playerFacingDirection":1,"rotationSpeed":{"_name":"rotationSpeed","_targetVariableID":"3a7d1c7c-8fb6-4a99-b25a-b434b62d4611"},"rotationSmoothing":{"_value":1.0},"gravityPower":{"_name":"gravityPower","_targetVariableID":"2221dc20-d9b3-4781-bd23-0b2038a7ff5e"},"$type":"NodeCanvas.Tasks.Actions.ProcessMovement"}]},"_position":{"x":-53.13062,"y":301.5233},"$type":"NodeCanvas.StateMachines.OnFSMEnter"}],"connections":[{"_condition":{"valueA":{"_name":"isGrounded","_targetVariableID":"619300a4-be8b-4ad4-ba2a-978468094ba2"},"valueB":{},"$type":"NodeCanvas.Tasks.Conditions.CheckBoolean"},"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"1"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"actionName":{"_value":"Jump"},"actionValue":{},"$type":"NodeCanvas.Tasks.Conditions.CheckInput"},"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"4"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"actionName":{"_value":"Grapple"},"actionValue":{},"$type":"NodeCanvas.Tasks.Conditions.CheckInput"},"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"7"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"conditions":[{"eventName":{"_value":"ForwardRay"},"value":{"_value":true},"$type":"NodeCanvas.Tasks.Conditions.CheckEventValue`1[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"},{"actionName":{"_value":"Jump"},"actionValue":{},"$type":"NodeCanvas.Tasks.Conditions.CheckInput"}],"$type":"NodeCanvas.Framework.ConditionList"},"_sourceNode":{"$ref":"1"},"_targetNode":{"$ref":"2"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"conditions":[{"actionName":{"_value":"Jump"},"actionValue":{},"$type":"NodeCanvas.Tasks.Conditions.CheckInput"},{"eventName":{"_value":"RightRay"},"$type":"NodeCanvas.Tasks.Conditions.CheckEvent"}],"$type":"NodeCanvas.Framework.ConditionList"},"_sourceNode":{"$ref":"1"},"_targetNode":{"$ref":"3"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"actionName":{"_value":"Jump"},"actionValue":{},"$type":"NodeCanvas.Tasks.Conditions.CheckInput"},"_sourceNode":{"$ref":"1"},"_targetNode":{"$ref":"4"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"valueA":{"_name":"airJumpsRemaining","_targetVariableID":"23f0ddc0-c4e8-462f-a7e0-fdd8e818d08d"},"valueB":{},"$type":"NodeCanvas.Tasks.Conditions.CheckInt"},"_sourceNode":{"$ref":"1"},"_targetNode":{"$ref":"5"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"valueA":{"_name":"isGrounded","_targetVariableID":"619300a4-be8b-4ad4-ba2a-978468094ba2"},"valueB":{"_value":true},"$type":"NodeCanvas.Tasks.Conditions.CheckBoolean"},"_sourceNode":{"$ref":"1"},"_targetNode":{"$ref":"0"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"conditions":[{"actionName":{"_value":"Jump"},"actionValue":{},"$type":"NodeCanvas.Tasks.Conditions.CheckInput"},{"eventName":{"_value":"LeftRay"},"$type":"NodeCanvas.Tasks.Conditions.CheckEvent"}],"$type":"NodeCanvas.Framework.ConditionList"},"_sourceNode":{"$ref":"1"},"_targetNode":{"$ref":"6"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_sourceNode":{"$ref":"2"},"_targetNode":{"$ref":"1"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_sourceNode":{"$ref":"3"},"_targetNode":{"$ref":"1"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_sourceNode":{"$ref":"4"},"_targetNode":{"$ref":"1"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"valueA":{"_name":"isGrounded","_targetVariableID":"619300a4-be8b-4ad4-ba2a-978468094ba2"},"valueB":{"_value":true},"$type":"NodeCanvas.Tasks.Conditions.CheckBoolean"},"_sourceNode":{"$ref":"5"},"_targetNode":{"$ref":"0"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_sourceNode":{"$ref":"6"},"_targetNode":{"$ref":"1"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"actionName":{"_value":"Grapple"},"actionValue":{},"$type":"NodeCanvas.Tasks.Conditions.CheckInput"},"_sourceNode":{"$ref":"7"},"_targetNode":{"$ref":"8"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_sourceNode":{"$ref":"8"},"_targetNode":{"$ref":"0"},"$type":"NodeCanvas.StateMachines.FSMConnection"}],"canvasGroups":[],"localBlackboard":{"_variables":{"isGrounded":{"_propertyPath":"UnityEngine.CharacterController.isGrounded","_name":"isGrounded","_id":"619300a4-be8b-4ad4-ba2a-978468094ba2","$type":"NodeCanvas.Framework.Variable`1[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"},"forwardRay":{"_propertyPath":"PlayerMovement.forwardRay","_name":"forwardRay","_id":"a2506ca5-1b47-4820-9921-3ff4ecc18564","$type":"NodeCanvas.Framework.Variable`1[[UnityEngine.RaycastHit, UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"},"airJumpsRemaining":{"_name":"airJumpsRemaining","_id":"23f0ddc0-c4e8-462f-a7e0-fdd8e818d08d","$type":"NodeCanvas.Framework.Variable`1[[System.Int32, @@ -6728,13 +6743,12 @@ MonoBehaviour: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"}}}}' _boundGraphObjectReferences: - {fileID: 0} - - {fileID: 402424904} - {fileID: 11400000, guid: b307c218c1a404548afe65e66737fa80, type: 2} _boundGraphSource: _version: 3.31 _category: _comments: - _translation: {x: 215, y: 546} + _translation: {x: 196, y: 37} _zoomFactor: 1 _firstActivation: 0 _enableAction: 0 diff --git a/Assets/Scripts/Core/Graph Tasks/ChangeCameraSettings.cs b/Assets/Scripts/Core/Graph Tasks/ChangeCameraSettings.cs index d25d8af..729b35f 100644 --- a/Assets/Scripts/Core/Graph Tasks/ChangeCameraSettings.cs +++ b/Assets/Scripts/Core/Graph Tasks/ChangeCameraSettings.cs @@ -1,49 +1,9 @@ using NodeCanvas.Framework; -using NodeCanvas.Tasks.Actions; using ParadoxNotion.Design; -using Sirenix.OdinInspector; using Unity.Cinemachine; using UnityEditor; using UnityEngine; -// TODO: Move this outta here but I don't know where to. Future organization task? There's also a shitty method down below in OnInit that calls this for every single instance of Change Camera Settings. -public static class OriginalCameraSettings{ - public static float orbitFollowTopHeight; - public static float orbitFollowTopRadius; - public static float orbitFollowCenterHeight; - public static float orbitFollowCenterRadius; - public static float orbitFollowBottomHeight; - public static float orbitFollowBottomRadius; - - public static Vector2 rotCompScreenPosition; - - public static bool valuesSaved; - - [InitializeOnEnterPlayMode] - public static void OnEnterPlaymodeInEditor(){ - // Unity Play Mode contingency - valuesSaved = false; - } - - public static void StashCameraOriginalSettings(GameObject cinemachine){ - if (valuesSaved == false) { - CinemachineOrbitalFollow orbit = cinemachine.GetComponent(); - - orbitFollowTopHeight = orbit.Orbits.Top.Height; - orbitFollowTopRadius = orbit.Orbits.Top.Radius; - orbitFollowCenterHeight = orbit.Orbits.Center.Height; - orbitFollowCenterRadius = orbit.Orbits.Center.Radius; - orbitFollowBottomHeight = orbit.Orbits.Bottom.Height; - orbitFollowBottomRadius = orbit.Orbits.Bottom.Radius; - - CinemachineRotationComposer rotComp = cinemachine.GetComponent(); - rotCompScreenPosition = rotComp.Composition.ScreenPosition; - - valuesSaved = true; - } - } -} - // Individual bool setting for each ring. Three of these will be used. public struct OrbitalFollowValueGroup{ public string label; @@ -63,16 +23,98 @@ public struct OrbitalFollowValueGroup{ } } +// Setting for any X and Y based values +public struct CinemachineVectorValueGroup{ + public CameraSettingsToggle changeX; + public float xValue; + public CameraSettingsToggle changeY; + public float yValue; +} + // Enum options for individual camera settings public enum CameraSettingsToggle{ NoChange, NewValue, - ResetValue + ResetValue, +} + +public struct Vector2CameraValueGroup{ + public string label; + public Vector2 newValue; + + public CameraSettingsToggle changeX; + public CameraSettingsToggle changeY; + + public Vector2CameraValueGroup(string newLabel){ + changeX = CameraSettingsToggle.NoChange; + changeY = CameraSettingsToggle.NoChange; + + newValue = Vector2.zero; + label = newLabel; + } +} + +public class Vector2CameraValueGroupDrawer : ObjectDrawer { + public override Vector2CameraValueGroup OnGUI(GUIContent _content, Vector2CameraValueGroup _instance){ + // Remove label for floats + EditorGUIUtility.labelWidth = 50; + + // Set layout options for the label and the float fields + GUILayoutOption[] floatOptions = new GUILayoutOption[] { + GUILayout.Width(300.0f), + GUILayout.MinWidth(20.0f), + GUILayout.ExpandWidth(true), + }; + + GUILayoutOption[] labelOptions = new GUILayoutOption[]{ + GUILayout.Width(200.0f), + }; + + // Start the Vertical layout then add the label before adding a horizontal so the label will be on top of side-by-side options + GUILayout.BeginVertical(); + GUILayout.Label(_instance.ToString(), labelOptions); + GUILayout.BeginHorizontal(); + + // Create the x settings enum + _instance.changeX = (CameraSettingsToggle)EditorGUILayout.EnumPopup("", instance.changeX); + + // Create the value/disabled information field + if (_instance.changeX == CameraSettingsToggle.NewValue){ + _instance.newValue.x = EditorGUILayout.FloatField(_instance.newValue.x, floatOptions); + } else { + EditorGUI.BeginDisabledGroup(true); + EditorGUILayout.TextField(_instance.changeX == CameraSettingsToggle.NoChange ? "Unchanged" : "Reset", floatOptions); + EditorGUI.EndDisabledGroup(); + } + + // It do what it do. + GUILayout.Space(5); + + // Create the y settings enum + _instance.changeY = (CameraSettingsToggle)EditorGUILayout.EnumPopup("", _instance.changeY); + + // Create the value/disabled information field + if (_instance.changeY == CameraSettingsToggle.NewValue){ + _instance.newValue.y = EditorGUILayout.FloatField(_instance.newValue.y, floatOptions); + } else { + EditorGUI.BeginDisabledGroup(true); + EditorGUILayout.TextField(_instance.changeY == CameraSettingsToggle.NoChange ? "Unchanged" : "Reset", floatOptions); + EditorGUI.EndDisabledGroup(); + } + + // Close this line up + GUILayout.EndHorizontal(); + GUILayout.EndVertical(); + + // Reset to default so the rest of things don't get messed up + EditorGUIUtility.labelWidth = 0; + return _instance; + } } // Custom editor for each orbital follow ring setting public class OrbitalFollowValueGroupDrawer : ObjectDrawer{ - public override OrbitalFollowValueGroup OnGUI(GUIContent content, OrbitalFollowValueGroup instance){ + public override OrbitalFollowValueGroup OnGUI(GUIContent _content, OrbitalFollowValueGroup _instance){ // Remove label for floats EditorGUIUtility.labelWidth = 1; @@ -91,17 +133,17 @@ public class OrbitalFollowValueGroupDrawer : ObjectDrawer cinemachine; - [Space(5)] - [ParadoxNotion.Design.Header("Orbit Follow Ring Settings")] public OrbitalFollowValueGroup orbitFollowTop = new OrbitalFollowValueGroup(newLabel: "Top"); public OrbitalFollowValueGroup orbitFollowCenter = new OrbitalFollowValueGroup(newLabel: "Center"); public OrbitalFollowValueGroup orbitFollowBottom = new OrbitalFollowValueGroup(newLabel: "Bottom"); - + [ParadoxNotion.Design.Header("Rotation Composer Settings")] - public bool changeScreenPosition; - [HideLabel] - public Vector2 screenPosition; + public Vector2CameraValueGroup screenPosition = new Vector2CameraValueGroup(newLabel: "Screen Position"); private CinemachineOrbitalFollow orbitalFollow; //Use for initialization. This is called only once in the lifetime of the task. //Return null if init was successfull. Return an error string otherwise protected override string OnInit(){ - // Check if cinemachine is referenced - try { - orbitalFollow = cinemachine.value.GetComponent(); - } catch { - Debug.LogError("Couldn't grab all references from the camera?"); - EndAction(false); - } - - // Save em. - OriginalCameraSettings.StashCameraOriginalSettings(cinemachine.value); - return null; } @@ -173,55 +198,81 @@ namespace NodeCanvas.Tasks.Actions { // Switch case farm for checking if values should be changed and what to switch (orbitFollowTop.changeHeight) { case CameraSettingsToggle.NewValue: - orbitalFollow.Orbits.Top.Height = orbitFollowTop.height; + CameraSettingsProcessor.values.orbitFollowTopHeight.targetValue = orbitFollowTop.height; break; case CameraSettingsToggle.ResetValue: - orbitalFollow.Orbits.Top.Height = OriginalCameraSettings.orbitFollowTopHeight; + CameraSettingsProcessor.values.orbitFollowTopHeight.Reset(); break; } switch (orbitFollowTop.changeRadius) { case CameraSettingsToggle.NewValue: - orbitalFollow.Orbits.Top.Radius = orbitFollowTop.radius; + CameraSettingsProcessor.values.orbitFollowTopRadius.targetValue = orbitFollowTop.radius; break; case CameraSettingsToggle.ResetValue: - orbitalFollow.Orbits.Top.Radius = OriginalCameraSettings.orbitFollowTopRadius; + CameraSettingsProcessor.values.orbitFollowTopRadius.Reset(); break; } switch (orbitFollowCenter.changeHeight) { case CameraSettingsToggle.NewValue: - orbitalFollow.Orbits.Center.Height = orbitFollowCenter.height; + CameraSettingsProcessor.values.orbitFollowCenterHeight.targetValue = orbitFollowCenter.height; break; case CameraSettingsToggle.ResetValue: - orbitalFollow.Orbits.Center.Height = OriginalCameraSettings.orbitFollowCenterHeight; + CameraSettingsProcessor.values.orbitFollowCenterHeight.Reset(); break; } switch (orbitFollowCenter.changeRadius) { case CameraSettingsToggle.NewValue: - orbitalFollow.Orbits.Center.Radius = orbitFollowCenter.radius; + CameraSettingsProcessor.values.orbitFollowCenterRadius.targetValue = orbitFollowCenter.radius; break; case CameraSettingsToggle.ResetValue: - orbitalFollow.Orbits.Center.Radius = OriginalCameraSettings.orbitFollowCenterRadius; + CameraSettingsProcessor.values.orbitFollowCenterRadius.Reset(); break; } switch (orbitFollowBottom.changeHeight) { case CameraSettingsToggle.NewValue: - orbitalFollow.Orbits.Bottom.Height = orbitFollowBottom.height; + CameraSettingsProcessor.values.orbitFollowBottomHeight.targetValue = orbitFollowBottom.height; break; case CameraSettingsToggle.ResetValue: - orbitalFollow.Orbits.Bottom.Height = OriginalCameraSettings.orbitFollowBottomHeight; + CameraSettingsProcessor.values.orbitFollowBottomHeight.Reset(); break; } switch (orbitFollowBottom.changeRadius) { case CameraSettingsToggle.NewValue: - orbitalFollow.Orbits.Bottom.Radius = orbitFollowBottom.radius; + CameraSettingsProcessor.values.orbitFollowBottomRadius.targetValue = orbitFollowBottom.radius; break; case CameraSettingsToggle.ResetValue: - orbitalFollow.Orbits.Bottom.Radius = OriginalCameraSettings.orbitFollowBottomRadius; + CameraSettingsProcessor.values.orbitFollowBottomRadius.Reset(); + break; + } + + switch (screenPosition.changeX) { + case CameraSettingsToggle.NewValue: + CameraSettingsProcessor.values.rotationComposerScreenPos.targetValue = new Vector2( + screenPosition.newValue.x, + CameraSettingsProcessor.values.rotationComposerScreenPos.originalValue.y); + break; + case CameraSettingsToggle.ResetValue: + CameraSettingsProcessor.values.rotationComposerScreenPos.targetValue = new Vector2( + CameraSettingsProcessor.values.rotationComposerScreenPos.originalValue.x, + CameraSettingsProcessor.values.rotationComposerScreenPos.originalValue.y); + break; + } + + switch (screenPosition.changeY) { + case CameraSettingsToggle.NewValue: + CameraSettingsProcessor.values.rotationComposerScreenPos.targetValue = new Vector2( + CameraSettingsProcessor.values.rotationComposerScreenPos.originalValue.x, + screenPosition.newValue.y); + break; + case CameraSettingsToggle.ResetValue: + CameraSettingsProcessor.values.rotationComposerScreenPos.targetValue = new Vector2( + CameraSettingsProcessor.values.rotationComposerScreenPos.originalValue.x, + CameraSettingsProcessor.values.rotationComposerScreenPos.originalValue.y); break; } diff --git a/Assets/Scripts/Player/CameraSettingsProcessor.cs b/Assets/Scripts/Player/CameraSettingsProcessor.cs new file mode 100644 index 0000000..18a09af --- /dev/null +++ b/Assets/Scripts/Player/CameraSettingsProcessor.cs @@ -0,0 +1,128 @@ +using Unity.Cinemachine; +using UnityEngine; + +public struct CameraSettingSingleValue{ + // NOTE: Could add a locked variable here if needed?? + public T originalValue; + public T targetValue; + public float smoothing; + + public float velocityRef; + public Vector2 velocityRefV2; + + public CameraSettingSingleValue(float defaultSmoothing, T original = default(T)){ + originalValue = original; + targetValue = default(T); + smoothing = defaultSmoothing; + + velocityRef = 0; + velocityRefV2 = default; + } + + public void Reset(){ + targetValue = originalValue; + } +} + +public struct CameraSettingValues{ + public CameraSettingSingleValue orbitFollowTopHeight; + public CameraSettingSingleValue orbitFollowTopRadius; + public CameraSettingSingleValue orbitFollowCenterHeight; + public CameraSettingSingleValue orbitFollowCenterRadius; + public CameraSettingSingleValue orbitFollowBottomHeight; + public CameraSettingSingleValue orbitFollowBottomRadius; + + public CameraSettingSingleValue rotationComposerScreenPos; + + public CameraSettingValues(float defaultSmoothing){ + orbitFollowTopHeight = new CameraSettingSingleValue(defaultSmoothing); + orbitFollowTopRadius = new CameraSettingSingleValue(defaultSmoothing); + orbitFollowCenterHeight = new CameraSettingSingleValue(defaultSmoothing); + orbitFollowCenterRadius = new CameraSettingSingleValue(defaultSmoothing); + orbitFollowBottomHeight = new CameraSettingSingleValue(defaultSmoothing); + orbitFollowBottomRadius = new CameraSettingSingleValue(defaultSmoothing); + + rotationComposerScreenPos = new CameraSettingSingleValue(defaultSmoothing); + } +} + +public class CameraSettingsProcessor : MonoBehaviour{ + public static CameraSettingsProcessor Instance{ get; private set; } + + public static CameraSettingValues values = new(defaultSmoothing: .2f); + + public static GameObject mainCamera; + + private CinemachineOrbitalFollow orbit; + private CinemachineRotationComposer rotComp; + + public void Awake(){ + if (Instance != null && Instance != this) { + Destroy(this); + } else { + Instance = this; + } + + mainCamera = gameObject; + orbit = mainCamera.GetComponent(); + rotComp = mainCamera.GetComponent(); + + StashCameraOriginalSettings(this); + SetTargetsToOriginalValues(this); + } + + public static void StashCameraOriginalSettings(CameraSettingsProcessor settings){ + values.orbitFollowTopHeight.originalValue = settings.orbit.Orbits.Top.Height; + values.orbitFollowTopRadius.originalValue = settings.orbit.Orbits.Top.Radius; + values.orbitFollowCenterHeight.originalValue = settings.orbit.Orbits.Center.Height; + values.orbitFollowCenterRadius.originalValue = settings.orbit.Orbits.Center.Radius; + values.orbitFollowBottomHeight.originalValue = settings.orbit.Orbits.Bottom.Height; + values.orbitFollowBottomRadius.originalValue = settings.orbit.Orbits.Bottom.Radius; + + values.rotationComposerScreenPos.originalValue = settings.rotComp.Composition.ScreenPosition; + } + + public static void SetTargetsToOriginalValues(CameraSettingsProcessor settings){ + values.orbitFollowTopHeight.Reset(); + values.orbitFollowTopRadius.Reset(); + values.orbitFollowCenterHeight.Reset(); + values.orbitFollowCenterRadius.Reset(); + values.orbitFollowBottomHeight.Reset(); + values.orbitFollowBottomRadius.Reset(); + values.rotationComposerScreenPos.Reset(); + } + + void ProcessCameraValues(){ + orbit.Orbits.Top.Height = Mathf.SmoothDamp(orbit.Orbits.Top.Height, + values.orbitFollowTopHeight.targetValue, ref values.orbitFollowTopHeight.velocityRef, + values.orbitFollowTopHeight.smoothing); + + orbit.Orbits.Top.Radius = Mathf.SmoothDamp(orbit.Orbits.Top.Radius, + values.orbitFollowTopRadius.targetValue, ref values.orbitFollowTopRadius.velocityRef, + values.orbitFollowTopRadius.smoothing); + + orbit.Orbits.Center.Height = Mathf.SmoothDamp(orbit.Orbits.Center.Height, + values.orbitFollowCenterHeight.targetValue, ref values.orbitFollowCenterHeight.velocityRef, + values.orbitFollowCenterHeight.smoothing); + + orbit.Orbits.Center.Radius = Mathf.SmoothDamp(orbit.Orbits.Center.Radius, + values.orbitFollowCenterRadius.targetValue, ref values.orbitFollowCenterRadius.velocityRef, + values.orbitFollowCenterRadius.smoothing); + + orbit.Orbits.Bottom.Height = Mathf.SmoothDamp(orbit.Orbits.Bottom.Height, + values.orbitFollowBottomHeight.targetValue, ref values.orbitFollowBottomHeight.velocityRef, + values.orbitFollowBottomHeight.smoothing); + + orbit.Orbits.Bottom.Radius = Mathf.SmoothDamp(orbit.Orbits.Bottom.Radius, + values.orbitFollowBottomRadius.targetValue, ref values.orbitFollowBottomRadius.velocityRef, + values.orbitFollowBottomRadius.smoothing); + + rotComp.Composition.ScreenPosition = Vector2.SmoothDamp(rotComp.Composition.ScreenPosition, + values.rotationComposerScreenPos.targetValue, ref values.rotationComposerScreenPos.velocityRefV2, + values.rotationComposerScreenPos.smoothing); + } + + void Update(){ + ProcessCameraValues(); + } +} diff --git a/Assets/Scripts/Player/CameraSettingsProcessor.cs.meta b/Assets/Scripts/Player/CameraSettingsProcessor.cs.meta new file mode 100644 index 0000000..069e56c --- /dev/null +++ b/Assets/Scripts/Player/CameraSettingsProcessor.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: c032a18b0b0c1da4092bfc365c6e4aad \ No newline at end of file diff --git a/Assets/Scripts/Player/PlayerControls.cs b/Assets/Scripts/Player/PlayerControls.cs index 881327f..2742493 100644 --- a/Assets/Scripts/Player/PlayerControls.cs +++ b/Assets/Scripts/Player/PlayerControls.cs @@ -50,12 +50,11 @@ public class PlayerControls : MonoBehaviour{ graph.SendEvent("InputEvent", "CancelLockOn", null); } - public void OnGrapple(InputInteractionContext context){ - if (context.control.IsPressed()) { - graph.SendEvent("InputEvent", "GrappleDown", null); - } else { - graph.SendEvent("InputEvent", "GrappleUp", null); - } - - } + // public void OnGrapple(InputInteractionContext context){ + // if (context.control.IsPressed()) { + // graph.SendEvent("InputEvent", "GrappleDown", null); + // } else { + // graph.SendEvent("InputEvent", "GrappleUp", null); + // } + // } }