From f84e8cfe5a2c10205ed16a0ebaff6841fbccbb6b Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 9 Jul 2025 14:46:16 -0400 Subject: [PATCH 1/7] added: initial input handling for grapple --- Assets/Player/Input/PlayerInputs.inputactions | 31 +++++++++++++++++++ Assets/Scripts/Player/PlayerControls.cs | 8 +++++ 2 files changed, 39 insertions(+) diff --git a/Assets/Player/Input/PlayerInputs.inputactions b/Assets/Player/Input/PlayerInputs.inputactions index 6962ce8..8c5c91a 100644 --- a/Assets/Player/Input/PlayerInputs.inputactions +++ b/Assets/Player/Input/PlayerInputs.inputactions @@ -58,6 +58,15 @@ "processors": "", "interactions": "", "initialStateCheck": false + }, + { + "name": "Grapple", + "type": "Button", + "id": "00393a1c-cfdb-46f8-8e02-552382b53236", + "expectedControlType": "", + "processors": "", + "interactions": "", + "initialStateCheck": false } ], "bindings": [ @@ -236,6 +245,28 @@ "action": "Cancel Lock-On", "isComposite": false, "isPartOfComposite": false + }, + { + "name": "", + "id": "62c22ef2-a01a-4fce-a688-9eb5fd35b9bc", + "path": "", + "interactions": "", + "processors": "", + "groups": "", + "action": "Grapple", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "3c93b098-1bd2-42c6-90d6-3eea7694acd0", + "path": "/rightTrigger", + "interactions": "", + "processors": "", + "groups": ";Controller", + "action": "Grapple", + "isComposite": false, + "isPartOfComposite": false } ] } diff --git a/Assets/Scripts/Player/PlayerControls.cs b/Assets/Scripts/Player/PlayerControls.cs index d6690cb..881327f 100644 --- a/Assets/Scripts/Player/PlayerControls.cs +++ b/Assets/Scripts/Player/PlayerControls.cs @@ -48,6 +48,14 @@ public class PlayerControls : MonoBehaviour{ public void OnCancelLockOn(){ GetComponent().RemoveLockOnTarget(); 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); + } + } } From ab79cd92ea16431d4ae6e7e5aba457fdbf99c803 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 10 Jul 2025 16:28:31 -0400 Subject: [PATCH 2/7] added: framework for changing camera settings --- Assets/Scenes/SampleScene.unity | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 4068df8..e99c39a 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -6711,13 +6711,13 @@ MonoBehaviour: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"},{"valueA":{"_name":"airMoveDirection","_targetVariableID":"8f5f926f-618d-4bcb-87eb-0bcd02e405a2"},"valueB":{"_name":"groundMoveDirection","_targetVariableID":"765d24b4-452d-4531-9fce-6cef7ba39634"},"$type":"NodeCanvas.Tasks.Actions.SetVariable`1[[UnityEngine.Vector3, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"}]},"_onUpdateList":{"executionMode":1,"actions":[]},"_onExitList":{"executionMode":1,"actions":[{"valueA":{"_name":"airMoveDirection","_targetVariableID":"8f5f926f-618d-4bcb-87eb-0bcd02e405a2"},"valueB":{"_name":"groundMoveDirection","_targetVariableID":"765d24b4-452d-4531-9fce-6cef7ba39634"},"$type":"NodeCanvas.Tasks.Actions.SetVariable`1[[UnityEngine.Vector3, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"}]},"foldEnter":true,"foldExit":true,"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_name":"Ground - Idle","_position":{"x":449.1072,"y":171.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 + 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":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"},{"_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":{"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"}],"canvasGroups":[],"localBlackboard":{"_variables":{"isGrounded":{"_propertyPath":"UnityEngine.CharacterController.isGrounded","_name":"isGrounded","_id":"619300a4-be8b-4ad4-ba2a-978468094ba2","$type":"NodeCanvas.Framework.Variable`1[[System.Boolean, + Jump","_position":{"x":328.7507,"y":-415.5261},"$type":"NodeCanvas.StateMachines.SuperActionState","$id":"6"},{"_actionList":{"executionMode":1,"actions":[{"cinemachine":{},"changeOrbitalFollowTopHeight":{},"orbitalFollowTopValues":{},"$type":"NodeCanvas.Tasks.Actions.ChangeCameraSettings"}]},"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_position":{"x":706.0,"y":406.0},"$type":"NodeCanvas.StateMachines.ActionState","$id":"7"},{"_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":"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, 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, @@ -6733,7 +6733,7 @@ MonoBehaviour: _version: 3.31 _category: _comments: - _translation: {x: 134, y: 549} + _translation: {x: 149, y: 411} _zoomFactor: 1 _firstActivation: 0 _enableAction: 0 From 1ffb90e425c17c10b2abee023827b8452e85a1a1 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 10 Jul 2025 18:59:00 -0400 Subject: [PATCH 3/7] added: camera settings change now functional, unfinished --- Assets/Player/Input/PlayerInputs.inputactions | 11 - Assets/Scenes/SampleScene.unity | 7 +- .../Core/Graph Tasks/ChangeCameraSettings.cs | 246 ++++++++++++++++++ .../Graph Tasks/ChangeCameraSettings.cs.meta | 2 + 4 files changed, 252 insertions(+), 14 deletions(-) create mode 100644 Assets/Scripts/Core/Graph Tasks/ChangeCameraSettings.cs create mode 100644 Assets/Scripts/Core/Graph Tasks/ChangeCameraSettings.cs.meta diff --git a/Assets/Player/Input/PlayerInputs.inputactions b/Assets/Player/Input/PlayerInputs.inputactions index 8c5c91a..d7d7365 100644 --- a/Assets/Player/Input/PlayerInputs.inputactions +++ b/Assets/Player/Input/PlayerInputs.inputactions @@ -246,17 +246,6 @@ "isComposite": false, "isPartOfComposite": false }, - { - "name": "", - "id": "62c22ef2-a01a-4fce-a688-9eb5fd35b9bc", - "path": "", - "interactions": "", - "processors": "", - "groups": "", - "action": "Grapple", - "isComposite": false, - "isPartOfComposite": false - }, { "name": "", "id": "3c93b098-1bd2-42c6-90d6-3eea7694acd0", diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index e99c39a..b2c5e96 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -6716,8 +6716,8 @@ 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":{},"changeOrbitalFollowTopHeight":{},"orbitalFollowTopValues":{},"$type":"NodeCanvas.Tasks.Actions.ChangeCameraSettings"}]},"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_position":{"x":706.0,"y":406.0},"$type":"NodeCanvas.StateMachines.ActionState","$id":"7"},{"_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":"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, + 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, + 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, 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, @@ -6728,12 +6728,13 @@ 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: 149, y: 411} + _translation: {x: 215, y: 546} _zoomFactor: 1 _firstActivation: 0 _enableAction: 0 diff --git a/Assets/Scripts/Core/Graph Tasks/ChangeCameraSettings.cs b/Assets/Scripts/Core/Graph Tasks/ChangeCameraSettings.cs new file mode 100644 index 0000000..d25d8af --- /dev/null +++ b/Assets/Scripts/Core/Graph Tasks/ChangeCameraSettings.cs @@ -0,0 +1,246 @@ +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; + + public CameraSettingsToggle changeHeight; + public float height; + + public CameraSettingsToggle changeRadius; + public float radius; + + public OrbitalFollowValueGroup(string newLabel){ + label = newLabel; + changeHeight = CameraSettingsToggle.NoChange; + height = 0f; + changeRadius = CameraSettingsToggle.NoChange; + radius = 0f; + } +} + +// Enum options for individual camera settings +public enum CameraSettingsToggle{ + NoChange, + NewValue, + ResetValue +} + +// Custom editor for each orbital follow ring setting +public class OrbitalFollowValueGroupDrawer : ObjectDrawer{ + public override OrbitalFollowValueGroup OnGUI(GUIContent content, OrbitalFollowValueGroup instance){ + // Remove label for floats + EditorGUIUtility.labelWidth = 1; + + // 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(60.0f), + }; + + // Start a Horiztonal Section + GUILayout.BeginHorizontal(); + + // Add the left side label + GUILayout.Label(instance.label, labelOptions); + + // Create the height settings enum + instance.changeHeight = (CameraSettingsToggle)EditorGUILayout.EnumPopup("", instance.changeHeight); + + // Create the value/disabled information field + if (instance.changeHeight == CameraSettingsToggle.NewValue){ + instance.height = EditorGUILayout.FloatField(instance.height, floatOptions); + } else { + EditorGUI.BeginDisabledGroup(true); + EditorGUILayout.TextField(instance.changeHeight == CameraSettingsToggle.NoChange ? "Unchanged" : "Reset", floatOptions); + EditorGUI.EndDisabledGroup(); + } + + // It do what it do. + GUILayout.Space(5); + + // Create the radius settings enum + instance.changeRadius = (CameraSettingsToggle)EditorGUILayout.EnumPopup("", instance.changeRadius); + + // Create the value/disabled information field + if (instance.changeRadius == CameraSettingsToggle.NewValue){ + instance.radius = EditorGUILayout.FloatField(instance.radius, floatOptions); + } else { + EditorGUI.BeginDisabledGroup(true); + EditorGUILayout.TextField(instance.changeRadius == CameraSettingsToggle.NoChange ? "Unchanged" : "Reset", floatOptions); + EditorGUI.EndDisabledGroup(); + } + + // Close this line up + GUILayout.EndHorizontal(); + + // Reset to default so the rest of things don't get messed up + EditorGUIUtility.labelWidth = 0; + return instance; + } +} + +namespace NodeCanvas.Tasks.Actions { + + [Category("Reset")] + [Description("Change Cinemachine camera settings for the player")] + public class ChangeCameraSettings : ActionTask{ + public BBParameter 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; + + 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; + } + + //This is called once each time the task is enabled. + //Call EndAction() to mark the action as finished, either in success or failure. + //EndAction can be called from anywhere. + protected override void OnExecute(){ + // 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; + break; + case CameraSettingsToggle.ResetValue: + orbitalFollow.Orbits.Top.Height = OriginalCameraSettings.orbitFollowTopHeight; + break; + } + + switch (orbitFollowTop.changeRadius) { + case CameraSettingsToggle.NewValue: + orbitalFollow.Orbits.Top.Radius = orbitFollowTop.radius; + break; + case CameraSettingsToggle.ResetValue: + orbitalFollow.Orbits.Top.Radius = OriginalCameraSettings.orbitFollowTopRadius; + break; + } + + switch (orbitFollowCenter.changeHeight) { + case CameraSettingsToggle.NewValue: + orbitalFollow.Orbits.Center.Height = orbitFollowCenter.height; + break; + case CameraSettingsToggle.ResetValue: + orbitalFollow.Orbits.Center.Height = OriginalCameraSettings.orbitFollowCenterHeight; + break; + } + + switch (orbitFollowCenter.changeRadius) { + case CameraSettingsToggle.NewValue: + orbitalFollow.Orbits.Center.Radius = orbitFollowCenter.radius; + break; + case CameraSettingsToggle.ResetValue: + orbitalFollow.Orbits.Center.Radius = OriginalCameraSettings.orbitFollowCenterRadius; + break; + } + + switch (orbitFollowBottom.changeHeight) { + case CameraSettingsToggle.NewValue: + orbitalFollow.Orbits.Bottom.Height = orbitFollowBottom.height; + break; + case CameraSettingsToggle.ResetValue: + orbitalFollow.Orbits.Bottom.Height = OriginalCameraSettings.orbitFollowBottomHeight; + break; + } + + switch (orbitFollowBottom.changeRadius) { + case CameraSettingsToggle.NewValue: + orbitalFollow.Orbits.Bottom.Radius = orbitFollowBottom.radius; + break; + case CameraSettingsToggle.ResetValue: + orbitalFollow.Orbits.Bottom.Radius = OriginalCameraSettings.orbitFollowBottomRadius; + break; + } + + EndAction(true); + } + + //Called once per frame while the action is active. + protected override void OnUpdate() { + + } + + //Called when the task is disabled. + protected override void OnStop() { + + } + + //Called when the task is paused. + protected override void OnPause() { + + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Core/Graph Tasks/ChangeCameraSettings.cs.meta b/Assets/Scripts/Core/Graph Tasks/ChangeCameraSettings.cs.meta new file mode 100644 index 0000000..9485a8e --- /dev/null +++ b/Assets/Scripts/Core/Graph Tasks/ChangeCameraSettings.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 87f3505b4ac62814ba2f782df47b0dbe \ No newline at end of file From c8f83603fd58882dae23672b10f167e0c37faa5e Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 10 Jul 2025 18:59:33 -0400 Subject: [PATCH 4/7] maint: hot reload automatic changes?? --- .../Editor/HotReloadAttributeProcessor.cs | 35 +++++++++++++++++++ .../HotReloadAttributeProcessor.cs.meta | 11 ++++++ 2 files changed, 46 insertions(+) create mode 100644 Packages/com.singularitygroup.hotreload/Editor/HotReloadAttributeProcessor.cs create mode 100644 Packages/com.singularitygroup.hotreload/Editor/HotReloadAttributeProcessor.cs.meta diff --git a/Packages/com.singularitygroup.hotreload/Editor/HotReloadAttributeProcessor.cs b/Packages/com.singularitygroup.hotreload/Editor/HotReloadAttributeProcessor.cs new file mode 100644 index 0000000..b99e2a6 --- /dev/null +++ b/Packages/com.singularitygroup.hotreload/Editor/HotReloadAttributeProcessor.cs @@ -0,0 +1,35 @@ +#if ODIN_INSPECTOR +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using SingularityGroup.HotReload.EditorDependencies; +using Sirenix.OdinInspector; +using Sirenix.OdinInspector.Editor; + +namespace SingularityGroup.HotReload.Editor { + public class HotReloadAttributeProcessor : OdinAttributeProcessor { + public override bool CanProcessChildMemberAttributes(InspectorProperty parentProperty, MemberInfo member) { + return member is FieldInfo; + } + + static object nullObject = new object(); + public override void ProcessChildMemberAttributes(InspectorProperty property, MemberInfo member, List attributes) { + var field = member as FieldInfo; + if (field?.DeclaringType == null) { + return; + } + if (UnityFieldHelper.TryGetFieldAttributes(field, out var fieldAttributes)) { + attributes.Clear(); + attributes.AddRange(fieldAttributes); + } + if (UnityFieldHelper.IsFieldHidden(field.DeclaringType, field.Name)) { + attributes.Add(new HideIfAttribute("@true")); + } + // we assume this is always not null. Most of the times it will not be. If it is the side effect is some memory footprint which hopefully gets cleared when enough objects + var key = property.ParentValues.FirstOrDefault() ?? nullObject; + UnityFieldHelper.CacheFieldInvalidation(key, field, property.RefreshSetup); + } + } +} +#endif diff --git a/Packages/com.singularitygroup.hotreload/Editor/HotReloadAttributeProcessor.cs.meta b/Packages/com.singularitygroup.hotreload/Editor/HotReloadAttributeProcessor.cs.meta new file mode 100644 index 0000000..22b1b82 --- /dev/null +++ b/Packages/com.singularitygroup.hotreload/Editor/HotReloadAttributeProcessor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c63452dd912fe4c46909c1c5ce844e69 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From a502b2d97a4962197d21147af4d1f30b311c324a Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 14 Jul 2025 14:22:50 -0400 Subject: [PATCH 5/7] 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 +++++++++++------- Assets/Scripts/Player/PlayerControls.cs | 15 +- 5 files changed, 177 insertions(+), 157 deletions(-) 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/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); + // } + // } } From bbfb583e3cf31cc8aa8c8e9adb3bf29e21928331 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 14 Jul 2025 14:22:50 -0400 Subject: [PATCH 6/7] 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); + // } + // } } From cb554175c325c344bcbc435d7a7c503bc0e20d7b Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 14 Jul 2025 15:46:26 -0400 Subject: [PATCH 7/7] 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(){