From cb554175c325c344bcbc435d7a7c503bc0e20d7b Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 14 Jul 2025 15:46:26 -0400 Subject: [PATCH] changed: fov and better offset. parallelized grapple change. --- Assets/Player/Graphs/GrappleAimBT.asset | 26 +++ Assets/Player/Graphs/GrappleAimBT.asset.meta | 8 + Assets/Scenes/SampleScene.unity | 33 ++- .../Core/Graph Tasks/ChangeCameraSettings.cs | 221 ++++++++++++++++-- .../Scripts/Player/CameraSettingsProcessor.cs | 62 +++-- 5 files changed, 298 insertions(+), 52 deletions(-) create mode 100644 Assets/Player/Graphs/GrappleAimBT.asset create mode 100644 Assets/Player/Graphs/GrappleAimBT.asset.meta diff --git a/Assets/Player/Graphs/GrappleAimBT.asset b/Assets/Player/Graphs/GrappleAimBT.asset new file mode 100644 index 0000000..acdf0c9 --- /dev/null +++ b/Assets/Player/Graphs/GrappleAimBT.asset @@ -0,0 +1,26 @@ +%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: 7a686a47eee2fa44cb0a34b5d86e4d5e, type: 3} + m_Name: GrappleAimBT + m_EditorClassIdentifier: + _serializedGraph: '{"type":"NodeCanvas.BehaviourTrees.BehaviourTree","nodes":[{"_position":{"x":730.5245,"y":284.5939},"$type":"NodeCanvas.BehaviourTrees.Sequencer","$id":"0"},{"_condition":{"actionName":{"_value":"Grapple"},"actionValue":{},"$type":"NodeCanvas.Tasks.Conditions.CheckInput"},"_position":{"x":498.9515,"y":429.918},"$type":"NodeCanvas.BehaviourTrees.WaitUntil","$id":"1"},{"_action":{"fieldOfView":{"label":"FOV","value":60.0,"changeValue":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},"cameraOffset":{"label":"Screen + Position","newValue":{"x":2.0,"z":-1.0},"changeX":1,"changeZ":1},"$type":"NodeCanvas.Tasks.Actions.ChangeCameraSettings"},"_position":{"x":527.6321,"y":581.3029},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"2"},{"_action":{"waitTime":{"_value":0.3},"$type":"NodeCanvas.Tasks.Actions.Wait"},"_position":{"x":682.4366,"y":430.895},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"3"},{"_condition":{"actionName":{"_value":"Grapple"},"actionValue":{},"$type":"NodeCanvas.Tasks.Conditions.CheckInput"},"_position":{"x":826.7462,"y":427.8908},"$type":"NodeCanvas.BehaviourTrees.WaitUntil","$id":"4"},{"_action":{"fieldOfView":{"label":"FOV","changeValue":2},"orbitFollowTop":{"label":"Top","changeHeight":2,"changeRadius":2},"orbitFollowCenter":{"label":"Center","changeHeight":2,"changeRadius":2},"orbitFollowBottom":{"label":"Bottom","changeHeight":2,"changeRadius":2},"screenPosition":{"label":"Screen + Position","changeX":2,"changeY":2},"cameraOffset":{"label":"Screen Position","changeX":2,"changeY":2,"changeZ":2},"$type":"NodeCanvas.Tasks.Actions.ChangeCameraSettings"},"_position":{"x":880.8403,"y":568.1857},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"5"}],"connections":[{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"1"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"3"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"4"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"1"},"_targetNode":{"$ref":"2"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"4"},"_targetNode":{"$ref":"5"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"}],"canvasGroups":[],"localBlackboard":{"_variables":{}},"derivedData":{"repeat":true,"$type":"NodeCanvas.BehaviourTrees.BehaviourTree+DerivedSerializationData"}}' + _objectReferences: [] + _graphSource: + _version: 3.31 + _category: + _comments: + _translation: {x: -21.80302, y: 59.90968} + _zoomFactor: 1 + _haltSerialization: 0 + _externalSerializationFile: {fileID: 0} diff --git a/Assets/Player/Graphs/GrappleAimBT.asset.meta b/Assets/Player/Graphs/GrappleAimBT.asset.meta new file mode 100644 index 0000000..f41ab03 --- /dev/null +++ b/Assets/Player/Graphs/GrappleAimBT.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c2ae6811bd56a6245a6ab9ec1b0503ae +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index da1a2f7..85a1905 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -2841,6 +2841,7 @@ GameObject: - component: {fileID: 402424910} - component: {fileID: 402424908} - component: {fileID: 402424912} + - component: {fileID: 402424913} m_Layer: 0 m_Name: Cinemachine m_TagString: Untagged @@ -2921,7 +2922,7 @@ MonoBehaviour: TargetOffset: {x: 0, y: 0, z: 0} TrackerSettings: BindingMode: 5 - PositionDamping: {x: 1, y: 1, z: 1} + PositionDamping: {x: 0.5, y: 1, z: 0.2} AngularDampingMode: 0 RotationDamping: {x: 0, y: 0, z: 0} QuaternionDamping: 1 @@ -3069,7 +3070,7 @@ MonoBehaviour: Enabled: 0 Size: {x: 0.8, y: 0.8} Offset: {x: 0, y: 0} - CenterOnActivate: 1 + CenterOnActivate: 0 TargetOffset: {x: 0, y: 1, z: 0} Damping: {x: 0.5, y: 0.5} Lookahead: @@ -3089,6 +3090,21 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: c032a18b0b0c1da4092bfc365c6e4aad, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &402424913 +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: 44d70cc20219cd84593f67d248eafe36, type: 3} + m_Name: + m_EditorClassIdentifier: + Offset: {x: 0, y: 0, z: 0} + ApplyAfter: 1 + PreserveComposition: 0 --- !u!1 &410087039 GameObject: m_ObjectHideFlags: 0 @@ -6727,12 +6743,12 @@ MonoBehaviour: Idle","_position":{"x":441.1072,"y":185.9887},"$type":"NodeCanvas.StateMachines.SuperActionState","$id":"0"},{"_onEnterList":{"executionMode":1,"actions":[{"valueA":{"_name":"airJumpsRemaining","_targetVariableID":"23f0ddc0-c4e8-462f-a7e0-fdd8e818d08d"},"Operation":2,"valueB":{"_value":1},"$type":"NodeCanvas.Tasks.Actions.SetInt"}]},"_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 (Actionable)","_position":{"x":607.037,"y":-147.5533},"$type":"NodeCanvas.StateMachines.SuperActionState","$id":"1"},{"_onEnterList":{"executionMode":1,"actions":[{"jumpStrength":{"_value":18.0},"airMoveDirection":{"_name":"airMoveDirection","_targetVariableID":"8f5f926f-618d-4bcb-87eb-0bcd02e405a2"},"standStillJumpStrength":{},"jumpPower":{"_name":"jumpPower","_targetVariableID":"9a82efee-e317-423c-ad6e-5ef7e6145396"},"currentVelocityInheritence":{"_value":0.2},"directionalForce":{"_value":{"y":1.0,"z":0.3}},"directionalForceStrength":{"_value":1.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 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":868.4374,"y":-419.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":[{"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, + Position","newValue":{"x":-0.25}},"cameraOffset":{"label":"Screen Position","newValue":{"x":2.0},"changeX":1},"$type":"NodeCanvas.Tasks.Actions.ChangeCameraSettings"}]},"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_position":{"x":803.9675,"y":376.7423},"$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},"cameraOffset":{"label":"Screen + Position","changeX":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":-257.669,"y":558.3375},"$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":-260.1776,"y":405.5469},"$type":"NodeCanvas.StateMachines.OnFSMEnter"},{"_subTree":{"_value":2},"_position":{"x":-29.75668,"y":553.0593},"$type":"NodeCanvas.StateMachines.ConcurrentSubTree"}],"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"},"_isDisabled":true,"$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"},"_isDisabled":true,"$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, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"},"groundMoveDirection":{"_name":"groundMoveDirection","_id":"765d24b4-452d-4531-9fce-6cef7ba39634","$type":"NodeCanvas.Framework.Variable`1[[UnityEngine.Vector3, @@ -6744,12 +6760,13 @@ MonoBehaviour: _boundGraphObjectReferences: - {fileID: 0} - {fileID: 11400000, guid: b307c218c1a404548afe65e66737fa80, type: 2} + - {fileID: 11400000, guid: c2ae6811bd56a6245a6ab9ec1b0503ae, type: 2} _boundGraphSource: _version: 3.31 _category: _comments: - _translation: {x: 196, y: 37} - _zoomFactor: 1 + _translation: {x: 542, y: 188} + _zoomFactor: 0.7910043 _firstActivation: 0 _enableAction: 0 _disableAction: 0 diff --git a/Assets/Scripts/Core/Graph Tasks/ChangeCameraSettings.cs b/Assets/Scripts/Core/Graph Tasks/ChangeCameraSettings.cs index 729b35f..9bd5ab6 100644 --- a/Assets/Scripts/Core/Graph Tasks/ChangeCameraSettings.cs +++ b/Assets/Scripts/Core/Graph Tasks/ChangeCameraSettings.cs @@ -38,6 +38,24 @@ public enum CameraSettingsToggle{ ResetValue, } +public struct Vector3CameraValueGroup{ + public string label; + public Vector3 newValue; + + public CameraSettingsToggle changeX; + public CameraSettingsToggle changeY; + public CameraSettingsToggle changeZ; + + public Vector3CameraValueGroup(string newLabel){ + changeX = CameraSettingsToggle.NoChange; + changeY = CameraSettingsToggle.NoChange; + changeZ = CameraSettingsToggle.NoChange; + + newValue = Vector3.zero; + label = newLabel; + } +} + public struct Vector2CameraValueGroup{ public string label; public Vector2 newValue; @@ -54,6 +72,135 @@ public struct Vector2CameraValueGroup{ } } +public struct FloatCameraValueGroup{ + public string label; + public float value; + + public CameraSettingsToggle changeValue; + + public FloatCameraValueGroup(string newLabel){ + label = newLabel; + value = 0f; + changeValue = CameraSettingsToggle.NoChange; + } +} + +public class FloatCameraValueGroupDrawer : ObjectDrawer { + public override FloatCameraValueGroup OnGUI(GUIContent _content, FloatCameraValueGroup _instance){ + // Remove label for floats + EditorGUIUtility.labelWidth = 50; + + // Set layout options for the label and the float fields + GUILayoutOption[] floatOptions = new GUILayoutOption[] { + GUILayout.Width(80.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.changeValue = (CameraSettingsToggle)EditorGUILayout.EnumPopup("", instance.changeValue); + + // Create the value/disabled information field + if (_instance.changeValue == CameraSettingsToggle.NewValue){ + _instance.value = EditorGUILayout.FloatField(_instance.value, floatOptions); + } else { + EditorGUI.BeginDisabledGroup(true); + EditorGUILayout.TextField(_instance.changeValue == 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; + } +} + +public class Vector3CameraValueGroupDrawer : ObjectDrawer { + public override Vector3CameraValueGroup OnGUI(GUIContent _content, Vector3CameraValueGroup _instance){ + // Remove label for floats + EditorGUIUtility.labelWidth = 20; + + // 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(); + } + + // It do what it do. + GUILayout.Space(5); + + // Create the y settings enum + _instance.changeZ = (CameraSettingsToggle)EditorGUILayout.EnumPopup("", _instance.changeZ); + + // Create the value/disabled information field + if (_instance.changeZ == CameraSettingsToggle.NewValue){ + _instance.newValue.z = EditorGUILayout.FloatField(_instance.newValue.z, floatOptions); + } else { + EditorGUI.BeginDisabledGroup(true); + EditorGUILayout.TextField(_instance.changeZ == 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; + } +} + public class Vector2CameraValueGroupDrawer : ObjectDrawer { public override Vector2CameraValueGroup OnGUI(GUIContent _content, Vector2CameraValueGroup _instance){ // Remove label for floats @@ -175,16 +322,20 @@ namespace NodeCanvas.Tasks.Actions { [Category("Reset")] [Description("Change Cinemachine camera settings for the player")] public class ChangeCameraSettings : ActionTask{ + [ParadoxNotion.Design.Header("Main Settings")] + public FloatCameraValueGroup fieldOfView = new (newLabel: "FOV"); + [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"); + public OrbitalFollowValueGroup orbitFollowTop = new (newLabel: "Top"); + public OrbitalFollowValueGroup orbitFollowCenter = new (newLabel: "Center"); + public OrbitalFollowValueGroup orbitFollowBottom = new (newLabel: "Bottom"); [ParadoxNotion.Design.Header("Rotation Composer Settings")] - public Vector2CameraValueGroup screenPosition = new Vector2CameraValueGroup(newLabel: "Screen Position"); + public Vector2CameraValueGroup screenPosition = new (newLabel: "Screen Position"); + + [ParadoxNotion.Design.Header("Camera Offset Settings")] + public Vector3CameraValueGroup cameraOffset = new (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(){ @@ -196,6 +347,17 @@ namespace NodeCanvas.Tasks.Actions { //EndAction can be called from anywhere. protected override void OnExecute(){ // Switch case farm for checking if values should be changed and what to + // Field of view + switch (fieldOfView.changeValue) { + case CameraSettingsToggle.NewValue: + CameraSettingsProcessor.values.mainFieldOfView.targetValue = fieldOfView.value; + break; + case CameraSettingsToggle.ResetValue: + CameraSettingsProcessor.values.mainFieldOfView.Reset(); + break; + } + + // Orbit follow rings switch (orbitFollowTop.changeHeight) { case CameraSettingsToggle.NewValue: CameraSettingsProcessor.values.orbitFollowTopHeight.targetValue = orbitFollowTop.height; @@ -250,29 +412,50 @@ namespace NodeCanvas.Tasks.Actions { break; } + // Screen Position switch (screenPosition.changeX) { case CameraSettingsToggle.NewValue: - CameraSettingsProcessor.values.rotationComposerScreenPos.targetValue = new Vector2( - screenPosition.newValue.x, - CameraSettingsProcessor.values.rotationComposerScreenPos.originalValue.y); - break; + CameraSettingsProcessor.values.rotationComposerScreenPos.targetValue.x = screenPosition.newValue.x; + break; case CameraSettingsToggle.ResetValue: - CameraSettingsProcessor.values.rotationComposerScreenPos.targetValue = new Vector2( - CameraSettingsProcessor.values.rotationComposerScreenPos.originalValue.x, - CameraSettingsProcessor.values.rotationComposerScreenPos.originalValue.y); + CameraSettingsProcessor.values.rotationComposerScreenPos.targetValue.x = CameraSettingsProcessor.values.rotationComposerScreenPos.originalValue.x; break; } switch (screenPosition.changeY) { case CameraSettingsToggle.NewValue: - CameraSettingsProcessor.values.rotationComposerScreenPos.targetValue = new Vector2( - CameraSettingsProcessor.values.rotationComposerScreenPos.originalValue.x, - screenPosition.newValue.y); + CameraSettingsProcessor.values.rotationComposerScreenPos.targetValue.y = screenPosition.newValue.y; break; case CameraSettingsToggle.ResetValue: - CameraSettingsProcessor.values.rotationComposerScreenPos.targetValue = new Vector2( - CameraSettingsProcessor.values.rotationComposerScreenPos.originalValue.x, - CameraSettingsProcessor.values.rotationComposerScreenPos.originalValue.y); + CameraSettingsProcessor.values.rotationComposerScreenPos.targetValue.y = CameraSettingsProcessor.values.rotationComposerScreenPos.originalValue.y; + break; + } + + // Camera Offset + switch (cameraOffset.changeX) { + case CameraSettingsToggle.NewValue: + CameraSettingsProcessor.values.cameraOffsetOffset.targetValue.x = cameraOffset.newValue.x; + break; + case CameraSettingsToggle.ResetValue: + CameraSettingsProcessor.values.cameraOffsetOffset.targetValue.x = CameraSettingsProcessor.values.cameraOffsetOffset.originalValue.x; + break; + } + + switch (cameraOffset.changeY) { + case CameraSettingsToggle.NewValue: + CameraSettingsProcessor.values.cameraOffsetOffset.targetValue.y = cameraOffset.newValue.y; + break; + case CameraSettingsToggle.ResetValue: + CameraSettingsProcessor.values.cameraOffsetOffset.targetValue.y = CameraSettingsProcessor.values.cameraOffsetOffset.originalValue.y; + break; + } + + switch (cameraOffset.changeZ) { + case CameraSettingsToggle.NewValue: + CameraSettingsProcessor.values.cameraOffsetOffset.targetValue.z = cameraOffset.newValue.z; + break; + case CameraSettingsToggle.ResetValue: + CameraSettingsProcessor.values.cameraOffsetOffset.targetValue.z = CameraSettingsProcessor.values.cameraOffsetOffset.originalValue.z; break; } diff --git a/Assets/Scripts/Player/CameraSettingsProcessor.cs b/Assets/Scripts/Player/CameraSettingsProcessor.cs index 18a09af..68f4d25 100644 --- a/Assets/Scripts/Player/CameraSettingsProcessor.cs +++ b/Assets/Scripts/Player/CameraSettingsProcessor.cs @@ -9,14 +9,16 @@ public struct CameraSettingSingleValue{ public float velocityRef; public Vector2 velocityRefV2; + public Vector3 velocityRefV3; public CameraSettingSingleValue(float defaultSmoothing, T original = default(T)){ originalValue = original; - targetValue = default(T); + targetValue = original; smoothing = defaultSmoothing; velocityRef = 0; velocityRefV2 = default; + velocityRefV3 = default; } public void Reset(){ @@ -25,6 +27,8 @@ public struct CameraSettingSingleValue{ } public struct CameraSettingValues{ + public CameraSettingSingleValue mainFieldOfView; + public CameraSettingSingleValue orbitFollowTopHeight; public CameraSettingSingleValue orbitFollowTopRadius; public CameraSettingSingleValue orbitFollowCenterHeight; @@ -33,8 +37,12 @@ public struct CameraSettingValues{ public CameraSettingSingleValue orbitFollowBottomRadius; public CameraSettingSingleValue rotationComposerScreenPos; + + public CameraSettingSingleValue cameraOffsetOffset; public CameraSettingValues(float defaultSmoothing){ + mainFieldOfView = new CameraSettingSingleValue(defaultSmoothing); + orbitFollowTopHeight = new CameraSettingSingleValue(defaultSmoothing); orbitFollowTopRadius = new CameraSettingSingleValue(defaultSmoothing); orbitFollowCenterHeight = new CameraSettingSingleValue(defaultSmoothing); @@ -43,6 +51,7 @@ public struct CameraSettingValues{ orbitFollowBottomRadius = new CameraSettingSingleValue(defaultSmoothing); rotationComposerScreenPos = new CameraSettingSingleValue(defaultSmoothing); + cameraOffsetOffset = new CameraSettingSingleValue(defaultSmoothing); } } @@ -53,46 +62,45 @@ public class CameraSettingsProcessor : MonoBehaviour{ public static GameObject mainCamera; + private CinemachineCamera main; private CinemachineOrbitalFollow orbit; private CinemachineRotationComposer rotComp; + private CinemachineCameraOffset offset; public void Awake(){ + // Singleton management if (Instance != null && Instance != this) { Destroy(this); } else { Instance = this; } + // Set references for camera object and cinemachine components mainCamera = gameObject; + main = mainCamera.GetComponent(); orbit = mainCamera.GetComponent(); rotComp = mainCamera.GetComponent(); + offset = mainCamera.GetComponent(); - StashCameraOriginalSettings(this); - SetTargetsToOriginalValues(this); + // Initialize camera settings values + values = new CameraSettingValues{ + cameraOffsetOffset = new CameraSettingSingleValue(defaultSmoothing: .2f, offset.Offset), + mainFieldOfView = new CameraSettingSingleValue(defaultSmoothing: .2f, main.Lens.FieldOfView), + orbitFollowTopHeight = new CameraSettingSingleValue(defaultSmoothing: .2f, orbit.Orbits.Top.Height), + orbitFollowTopRadius = new CameraSettingSingleValue(defaultSmoothing: .2f, orbit.Orbits.Top.Radius), + orbitFollowCenterHeight = new CameraSettingSingleValue(defaultSmoothing: .2f, orbit.Orbits.Center.Height), + orbitFollowCenterRadius = new CameraSettingSingleValue(defaultSmoothing: .2f, orbit.Orbits.Center.Radius), + orbitFollowBottomHeight = new CameraSettingSingleValue(defaultSmoothing: .2f, orbit.Orbits.Bottom.Height), + orbitFollowBottomRadius = new CameraSettingSingleValue(defaultSmoothing: .2f, orbit.Orbits.Bottom.Radius), + rotationComposerScreenPos = new CameraSettingSingleValue(defaultSmoothing: .2f, rotComp.Composition.ScreenPosition), + }; } - - 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(){ + main.Lens.FieldOfView = Mathf.SmoothDamp(main.Lens.FieldOfView, + values.mainFieldOfView.targetValue, ref values.mainFieldOfView.velocityRef, + values.mainFieldOfView.smoothing); + orbit.Orbits.Top.Height = Mathf.SmoothDamp(orbit.Orbits.Top.Height, values.orbitFollowTopHeight.targetValue, ref values.orbitFollowTopHeight.velocityRef, values.orbitFollowTopHeight.smoothing); @@ -120,6 +128,10 @@ public class CameraSettingsProcessor : MonoBehaviour{ rotComp.Composition.ScreenPosition = Vector2.SmoothDamp(rotComp.Composition.ScreenPosition, values.rotationComposerScreenPos.targetValue, ref values.rotationComposerScreenPos.velocityRefV2, values.rotationComposerScreenPos.smoothing); + + offset.Offset = Vector3.SmoothDamp(offset.Offset, + values.cameraOffsetOffset.targetValue, ref values.cameraOffsetOffset.velocityRefV3, + values.cameraOffsetOffset.smoothing); } void Update(){