changed: tweaks to make grapple feel better

This commit is contained in:
Chris
2025-08-17 14:37:33 -04:00
parent 6e4ab86d51
commit 93634a9586
8 changed files with 194 additions and 139 deletions

View File

@@ -16,7 +16,7 @@ MonoBehaviour:
Damping","newValue":{"x":0.2,"z":0.2},"changeX":1,"changeZ":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.2,"changeRadius":1,"radius":0.8},"cameraOffset":{"label":"Screen Damping","newValue":{"x":0.2,"z":0.2},"changeX":1,"changeZ":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.2,"changeRadius":1,"radius":0.8},"cameraOffset":{"label":"Screen
Position","newValue":{"x":2.0,"y":0.5,"z":-1.0},"changeX":1,"changeY":1,"changeZ":1},"$type":"NodeCanvas.Tasks.Actions.ChangeCameraSettings"},"_position":{"x":-139.3679,"y":620.3029},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"2"},{"_action":{"actions":[{"eventName":{"_value":"Grapple Position","newValue":{"x":2.0,"y":0.5,"z":-1.0},"changeX":1,"changeY":1,"changeZ":1},"$type":"NodeCanvas.Tasks.Actions.ChangeCameraSettings"},"_position":{"x":-139.3679,"y":620.3029},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"2"},{"_action":{"actions":[{"eventName":{"_value":"Grapple
Aimed"},"delay":{},"$type":"NodeCanvas.Tasks.Actions.SendEvent"},{"valueA":{"_name":"facingDirection","_targetVariableID":"c4e68b75-5129-428c-8177-abb7b38986f5"},"valueB":{"_value":2},"$type":"NodeCanvas.Tasks.Actions.SetVariable`1[[PlayerFacingDirection, Aimed"},"delay":{},"$type":"NodeCanvas.Tasks.Actions.SendEvent"},{"valueA":{"_name":"facingDirection","_targetVariableID":"c4e68b75-5129-428c-8177-abb7b38986f5"},"valueB":{"_value":2},"$type":"NodeCanvas.Tasks.Actions.SetVariable`1[[PlayerFacingDirection,
Core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"}],"$type":"NodeCanvas.Framework.ActionList"},"_position":{"x":91.0,"y":526.0},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"3"},{"_condition":{"actionName":{"_value":"Grapple"},"actionPhase":{"_value":4},"$type":"NodeCanvas.Tasks.Conditions.CheckInput"},"_position":{"x":336.0,"y":511.0},"$type":"NodeCanvas.BehaviourTrees.WaitUntil","$id":"4"},{"_action":{"boolVariable":{"_name":"_castHit"},"setTo":0,"$type":"NodeCanvas.Tasks.Actions.SetBoolean"},"_position":{"x":568.0,"y":515.0},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"5"},{"policy":1,"dynamic":true,"_position":{"x":749.7742,"y":517.9701},"$type":"NodeCanvas.BehaviourTrees.Parallel","$id":"6"},{"repeaterMode":2,"repeatTimes":{"_value":1},"_position":{"x":247.0,"y":763.0},"$type":"NodeCanvas.BehaviourTrees.Repeater","$id":"7"},{"_condition":{"castType":{"_value":4},"length":{"_value":20.0},"direction":{"_value":{"z":1.0}},"offset":{},"ignoreLayers":{"_value":{"value":8}},"width":{"_value":3.0},"size":{},"rotation":{},"drawGizmos":true,"outputHit":{"_name":"_hit"},"overrideAgent":{"_type":"UnityEngine.Transform","_name":"camera","_targetVariableID":"e1cfd0be-7f55-420d-bdd8-e72531fc61ba"},"$type":"Reset.CheckGenericObserver"},"_position":{"x":209.0,"y":870.0},"$type":"NodeCanvas.BehaviourTrees.BinarySelector","$id":"8"},{"_action":{"boolVariable":{"_name":"_castHit"},"$type":"NodeCanvas.Tasks.Actions.SetBoolean"},"_position":{"x":127.0,"y":975.0},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"9"},{"_action":{"boolVariable":{"_name":"_castHit"},"setTo":0,"$type":"NodeCanvas.Tasks.Actions.SetBoolean"},"_position":{"x":320.0,"y":973.0},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"10"},{"_position":{"x":841.0,"y":848.0},"$type":"NodeCanvas.BehaviourTrees.Sequencer","$id":"11"},{"_condition":{"actionName":{"_value":"Grapple"},"actionPhase":{"_value":3},"$type":"NodeCanvas.Tasks.Conditions.CheckInput"},"_position":{"x":540.0,"y":973.0},"$type":"NodeCanvas.BehaviourTrees.WaitUntil","$id":"12"},{"_condition":{"valueA":{"_name":"_castHit"},"valueB":{"_value":true},"$type":"NodeCanvas.Tasks.Conditions.CheckBoolean"},"_position":{"x":569.0,"y":1078.0},"$type":"NodeCanvas.BehaviourTrees.ConditionalEvaluator","$id":"13"},{"_action":{"actions":[{"raycastHit":{"_name":"_hit"},"transform":{},"collider":{},"gameObject":{},"distance":{},"normal":{},"point":{"_name":"_hitPoint"},"$type":"NodeCanvas.Tasks.Actions.DecomposeRaycastHit"},{"objectName":{"_value":"Hit Core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"}],"$type":"NodeCanvas.Framework.ActionList"},"_position":{"x":91.00002,"y":524.9998},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"3"},{"_condition":{"actionName":{"_value":"Grapple"},"actionPhase":{"_value":4},"$type":"NodeCanvas.Tasks.Conditions.CheckInput"},"_position":{"x":336.0,"y":511.0},"$type":"NodeCanvas.BehaviourTrees.WaitUntil","$id":"4"},{"_action":{"boolVariable":{"_name":"_castHit"},"setTo":0,"$type":"NodeCanvas.Tasks.Actions.SetBoolean"},"_position":{"x":568.0,"y":515.0},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"5"},{"policy":1,"dynamic":true,"_position":{"x":749.7742,"y":517.9701},"$type":"NodeCanvas.BehaviourTrees.Parallel","$id":"6"},{"repeaterMode":2,"repeatTimes":{"_value":1},"_position":{"x":247.0,"y":763.0},"$type":"NodeCanvas.BehaviourTrees.Repeater","$id":"7"},{"_condition":{"castType":{"_value":4},"length":{"_value":80.0},"direction":{"_value":{"z":1.0}},"offset":{},"ignoreLayers":{"_value":{"value":8}},"width":{"_value":3.0},"size":{},"rotation":{},"drawGizmos":true,"outputHit":{"_name":"_hit"},"overrideAgent":{"_type":"UnityEngine.Transform","_name":"camera","_targetVariableID":"e1cfd0be-7f55-420d-bdd8-e72531fc61ba"},"$type":"Reset.CheckGenericObserver"},"_position":{"x":209.0,"y":870.0},"$type":"NodeCanvas.BehaviourTrees.BinarySelector","$id":"8"},{"_action":{"boolVariable":{"_name":"_castHit"},"$type":"NodeCanvas.Tasks.Actions.SetBoolean"},"_position":{"x":127.0,"y":975.0},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"9"},{"_action":{"boolVariable":{"_name":"_castHit"},"setTo":0,"$type":"NodeCanvas.Tasks.Actions.SetBoolean"},"_position":{"x":320.0,"y":973.0},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"10"},{"_position":{"x":841.0,"y":848.0},"$type":"NodeCanvas.BehaviourTrees.Sequencer","$id":"11"},{"_condition":{"actionName":{"_value":"Grapple"},"actionPhase":{"_value":3},"$type":"NodeCanvas.Tasks.Conditions.CheckInput"},"_position":{"x":540.0,"y":973.0},"$type":"NodeCanvas.BehaviourTrees.WaitUntil","$id":"12"},{"_condition":{"valueA":{"_name":"_castHit"},"valueB":{"_value":true},"$type":"NodeCanvas.Tasks.Conditions.CheckBoolean"},"_position":{"x":569.0,"y":1078.0},"$type":"NodeCanvas.BehaviourTrees.ConditionalEvaluator","$id":"13"},{"_action":{"actions":[{"raycastHit":{"_name":"_hit"},"transform":{},"collider":{},"gameObject":{},"distance":{},"normal":{},"point":{"_name":"_hitPoint"},"$type":"NodeCanvas.Tasks.Actions.DecomposeRaycastHit"},{"objectName":{"_value":"Hit
Point"},"position":{"_name":"_hitPoint"},"rotation":{},"saveAs":{"_name":"_hitPointObject"},"$type":"NodeCanvas.Tasks.Actions.CreateGameObject"},{"relatedObject":{"_name":"_hitPointObject"},"weight":{"_value":0.15},"isMain":{"_value":true},"$type":"NodeCanvas.Tasks.Actions.UpdateObjectCameraTracking"}],"$type":"NodeCanvas.Framework.ActionList"},"_tag":"","_position":{"x":362.2634,"y":1221.254},"_comment":"","$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"14"},{"_position":{"x":852.0,"y":973.0},"$type":"NodeCanvas.BehaviourTrees.Inverter","$id":"15"},{"_condition":{"actionName":{"_value":"Grapple"},"actionPhase":{"_value":4},"$type":"NodeCanvas.Tasks.Conditions.CheckInput"},"_position":{"x":799.0,"y":1035.0},"$type":"NodeCanvas.BehaviourTrees.Interruptor","$id":"16"},{"repeaterMode":2,"repeatTimes":{"_value":1},"_position":{"x":902.6089,"y":1145.236},"$type":"NodeCanvas.BehaviourTrees.Repeater","$id":"17"},{"_position":{"x":912.0,"y":1202.0},"$type":"NodeCanvas.BehaviourTrees.Sequencer","$id":"18"},{"_action":{"enableXAxis":{"label":"Input Point"},"position":{"_name":"_hitPoint"},"rotation":{},"saveAs":{"_name":"_hitPointObject"},"$type":"NodeCanvas.Tasks.Actions.CreateGameObject"},{"relatedObject":{"_name":"_hitPointObject"},"weight":{"_value":0.15},"isMain":{"_value":true},"$type":"NodeCanvas.Tasks.Actions.UpdateObjectCameraTracking"}],"$type":"NodeCanvas.Framework.ActionList"},"_tag":"","_position":{"x":362.2634,"y":1221.254},"_comment":"","$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"14"},{"_position":{"x":852.0,"y":973.0},"$type":"NodeCanvas.BehaviourTrees.Inverter","$id":"15"},{"_condition":{"actionName":{"_value":"Grapple"},"actionPhase":{"_value":4},"$type":"NodeCanvas.Tasks.Conditions.CheckInput"},"_position":{"x":799.0,"y":1035.0},"$type":"NodeCanvas.BehaviourTrees.Interruptor","$id":"16"},{"repeaterMode":2,"repeatTimes":{"_value":1},"_position":{"x":902.6089,"y":1145.236},"$type":"NodeCanvas.BehaviourTrees.Repeater","$id":"17"},{"_position":{"x":912.0,"y":1202.0},"$type":"NodeCanvas.BehaviourTrees.Sequencer","$id":"18"},{"_action":{"enableXAxis":{"label":"Input
Axis X Enabled","changeValue":1},"enableYAxis":{"label":"Input Axis Y Enabled","changeValue":1},"$type":"NodeCanvas.Tasks.Actions.ChangeCameraSettings"},"_position":{"x":700.5458,"y":1355.854},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"19"},{"_action":{"actions":[{"actionName":{"_value":"Look"},"outputTo":{"_name":"_lookDir"},"$type":"NodeCanvas.Tasks.Actions.CheckInputValue`1[[UnityEngine.Vector2, Axis X Enabled","changeValue":1},"enableYAxis":{"label":"Input Axis Y Enabled","changeValue":1},"$type":"NodeCanvas.Tasks.Actions.ChangeCameraSettings"},"_position":{"x":700.5458,"y":1355.854},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"19"},{"_action":{"actions":[{"actionName":{"_value":"Look"},"outputTo":{"_name":"_lookDir"},"$type":"NodeCanvas.Tasks.Actions.CheckInputValue`1[[UnityEngine.Vector2,
UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"},{"targetVector":{"_name":"_lookDir"},"x":{"_name":""},"y":{"_name":"_lookDirY"},"z":{"_name":""},"$type":"NodeCanvas.Tasks.Actions.DecomposeVector"}],"$type":"NodeCanvas.Framework.ActionList"},"_position":{"x":903.6424,"y":1356.633},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"20"},{"_condition":{"valueA":{"_name":"_lookDirY"},"checkType":1,"valueB":{"_value":0.5},"differenceThreshold":0.1,"$type":"NodeCanvas.Tasks.Conditions.CheckFloat"},"_position":{"x":1186.228,"y":1367.689},"$type":"NodeCanvas.BehaviourTrees.BinarySelector","$id":"21"},{"_action":{"actions":[{"orbitTargetOffset":{"label":"Target UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"},{"targetVector":{"_name":"_lookDir"},"x":{"_name":""},"y":{"_name":"_lookDirY"},"z":{"_name":""},"$type":"NodeCanvas.Tasks.Actions.DecomposeVector"}],"$type":"NodeCanvas.Framework.ActionList"},"_position":{"x":903.6424,"y":1356.633},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"20"},{"_condition":{"valueA":{"_name":"_lookDirY"},"checkType":1,"valueB":{"_value":0.5},"differenceThreshold":0.1,"$type":"NodeCanvas.Tasks.Conditions.CheckFloat"},"_position":{"x":1186.228,"y":1367.689},"$type":"NodeCanvas.BehaviourTrees.BinarySelector","$id":"21"},{"_action":{"actions":[{"orbitTargetOffset":{"label":"Target
@@ -42,7 +42,7 @@ MonoBehaviour:
_version: 3.31 _version: 3.31
_category: _category:
_comments: _comments:
_translation: {x: 53, y: -224} _translation: {x: 180, y: -268}
_zoomFactor: 0.9998386 _zoomFactor: 0.9998386
_haltSerialization: 0 _haltSerialization: 0
_externalSerializationFile: {fileID: 0} _externalSerializationFile: {fileID: 0}

View File

@@ -12,13 +12,13 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 7a686a47eee2fa44cb0a34b5d86e4d5e, type: 3} m_Script: {fileID: 11500000, guid: 7a686a47eee2fa44cb0a34b5d86e4d5e, type: 3}
m_Name: GroundedCheckBT m_Name: GroundedCheckBT
m_EditorClassIdentifier: m_EditorClassIdentifier:
_serializedGraph: '{"type":"NodeCanvas.BehaviourTrees.BehaviourTree","nodes":[{"repeaterMode":2,"repeatTimes":{"_value":1},"_position":{"x":476.0,"y":327.0},"$type":"NodeCanvas.BehaviourTrees.Repeater","$id":"0"},{"_position":{"x":550.0,"y":433.0},"$type":"NodeCanvas.BehaviourTrees.Sequencer","$id":"1"},{"_condition":{"valueA":{"_name":"isGrounded","_targetVariableID":"09b3259f-8b50-439a-ab86-ea3d8a4916f1"},"valueB":{},"$type":"NodeCanvas.Tasks.Conditions.CheckBoolean"},"_position":{"x":458.0,"y":521.0},"$type":"NodeCanvas.BehaviourTrees.WaitUntil","$id":"2"},{"_position":{"x":478.0,"y":709.0},"$type":"NodeCanvas.BehaviourTrees.Sequencer","$id":"3"},{"_action":{"airMoveDirection":{"_name":"airMoveDirection","_targetVariableID":"2fc91db6-09dd-4a1f-9195-426a0c44de31"},"inputVector3":{"_name":"groundMoveDirection","_targetVariableID":"a2c4fe25-9549-4bdd-8cec-2dbfc4a8856f"},"$type":"NodeCanvas.Tasks.Actions.SetAirMovement"},"_position":{"x":294.0,"y":816.0},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"4"},{"_action":{"airMoveDirection":{"_name":"groundMoveDirection","_targetVariableID":"a2c4fe25-9549-4bdd-8cec-2dbfc4a8856f"},"inputVector3":{},"$type":"NodeCanvas.Tasks.Actions.SetAirMovement"},"_position":{"x":471.0,"y":817.0},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"5"},{"_condition":{"valueA":{"_name":"isGrounded","_targetVariableID":"09b3259f-8b50-439a-ab86-ea3d8a4916f1"},"valueB":{"_value":true},"$type":"NodeCanvas.Tasks.Conditions.CheckBoolean"},"_position":{"x":715.0,"y":523.0},"$type":"NodeCanvas.BehaviourTrees.WaitUntil","$id":"6"}],"connections":[{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"1"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"1"},"_targetNode":{"$ref":"2"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"1"},"_targetNode":{"$ref":"6"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"2"},"_targetNode":{"$ref":"3"},"_isDisabled":true,"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"3"},"_targetNode":{"$ref":"4"},"_isDisabled":true,"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"3"},"_targetNode":{"$ref":"5"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"}],"canvasGroups":[],"localBlackboard":{"_variables":{}},"derivedData":{"repeat":true,"$type":"NodeCanvas.BehaviourTrees.BehaviourTree+DerivedSerializationData"}}' _serializedGraph: '{"type":"NodeCanvas.BehaviourTrees.BehaviourTree","nodes":[{"repeaterMode":2,"repeatTimes":{"_value":1},"_position":{"x":476.0,"y":327.0},"$type":"NodeCanvas.BehaviourTrees.Repeater","$id":"0"},{"_position":{"x":550.0,"y":433.0},"$type":"NodeCanvas.BehaviourTrees.Sequencer","$id":"1"},{"_condition":{"valueA":{"_name":"isGrounded","_targetVariableID":"09b3259f-8b50-439a-ab86-ea3d8a4916f1"},"valueB":{},"$type":"NodeCanvas.Tasks.Conditions.CheckBoolean"},"_position":{"x":458.0,"y":521.0},"$type":"NodeCanvas.BehaviourTrees.WaitUntil","$id":"2"},{"_position":{"x":478.0,"y":709.0},"$type":"NodeCanvas.BehaviourTrees.Sequencer","$id":"3"},{"_condition":{"valueA":{"_name":"isGrounded","_targetVariableID":"09b3259f-8b50-439a-ab86-ea3d8a4916f1"},"valueB":{"_value":true},"$type":"NodeCanvas.Tasks.Conditions.CheckBoolean"},"_position":{"x":715.0,"y":523.0},"$type":"NodeCanvas.BehaviourTrees.WaitUntil","$id":"4"}],"connections":[{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"1"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"1"},"_targetNode":{"$ref":"2"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"1"},"_targetNode":{"$ref":"4"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"2"},"_targetNode":{"$ref":"3"},"_isDisabled":true,"$type":"NodeCanvas.BehaviourTrees.BTConnection"}],"canvasGroups":[],"localBlackboard":{"_variables":{}},"derivedData":{"repeat":true,"$type":"NodeCanvas.BehaviourTrees.BehaviourTree+DerivedSerializationData"}}'
_objectReferences: [] _objectReferences: []
_graphSource: _graphSource:
_version: 3.31 _version: 3.31
_category: _category:
_comments: _comments:
_translation: {x: 444, y: -12} _translation: {x: 442.93335, y: -225.00038}
_zoomFactor: 1 _zoomFactor: 1
_haltSerialization: 0 _haltSerialization: 0
_externalSerializationFile: {fileID: 0} _externalSerializationFile: {fileID: 0}

View File

@@ -1,15 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 44d2c5333075d6b4e80311cb6820c5f1 guid: 44d2c5333075d6b4e80311cb6820c5f1
timeCreated: 1539386928
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 100
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin: AssetOrigin:
serializedVersion: 1 serializedVersion: 1
productId: 14914 productId: 14914
@@ -17,3 +7,12 @@ AssetOrigin:
packageVersion: 3.3.1 packageVersion: 3.3.1
assetPath: Assets/ParadoxNotion/CanvasCore/Common/Runtime/Services/MonoManager.cs assetPath: Assets/ParadoxNotion/CanvasCore/Common/Runtime/Services/MonoManager.cs
uploadId: 704937 uploadId: 704937
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 90
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because one or more lines are too long

View File

@@ -2,6 +2,7 @@ using Drawing;
using NodeCanvas.Framework; using NodeCanvas.Framework;
using ParadoxNotion.Design; using ParadoxNotion.Design;
using ParadoxNotion.Services; using ParadoxNotion.Services;
using Reset.Units;
using UnityEngine; using UnityEngine;
@@ -9,7 +10,7 @@ namespace NodeCanvas.Tasks.Actions {
[Category("Reset/Movement")] [Category("Reset/Movement")]
[Description("Pulls the agent towards a position with a spring-like effect")] [Description("Pulls the agent towards a position with a spring-like effect")]
public class DoGrapplePull : ActionTask<CharacterController>{ public class DoGrapplePull : ActionTask<UnitMovementHandler>{
public BBParameter<Vector3> grapplePoint; public BBParameter<Vector3> grapplePoint;
public BBParameter<Vector3> offset; public BBParameter<Vector3> offset;
@@ -26,17 +27,25 @@ namespace NodeCanvas.Tasks.Actions {
public BBParameter<AnimationCurve> pullSpeedCurve; public BBParameter<AnimationCurve> pullSpeedCurve;
public BBParameter<AnimationCurve> endDeaccelerationCurve; public BBParameter<AnimationCurve> endDeaccelerationCurve;
private float startTime; private float startTime;
private Vector3 originalDirection;
public float breakAtDistance;
public float breakAtDotProduct;
private float currentSpeed; private float currentSpeed;
private Vector3 smoothedInput; private Vector3 smoothedInput;
private Vector3 smoothedInputRefVelocity; private Vector3 smoothedInputRefVelocity;
private Vector3 gizmoHookPoint;
private Transform camera;
//Use for initialization. This is called only once in the lifetime of the task. //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 //Return null if init was successfull. Return an error string otherwise
protected override string OnInit(){ protected override string OnInit(){
MonoManager.current.onLateUpdate += DrawGrappleGizmo;
return null; return null;
} }
@@ -44,14 +53,25 @@ namespace NodeCanvas.Tasks.Actions {
//Call EndAction() to mark the action as finished, either in success or failure. //Call EndAction() to mark the action as finished, either in success or failure.
//EndAction can be called from anywhere. //EndAction can be called from anywhere.
protected override void OnExecute(){ protected override void OnExecute(){
camera = Camera.main.transform;
MonoManager.current.onLateUpdate += DrawGrappleGizmo;
originalDirection = agent.transform.position.DirectionTo(grapplePoint.value);
startTime = Time.time; startTime = Time.time;
currentSpeed = pullSpeedCurve.value[0].value * pullSpeedRange.value.y; currentSpeed = pullSpeedCurve.value[0].value * pullSpeedRange.value.y;
} }
//Called once per frame while the action is active. //Called once per frame while the action is active.
protected override void OnUpdate(){ protected override void OnUpdate(){
// Add input changes
Vector2 rawInput = agent.GetComponent<PlayerControls>().rawMoveInput;
Vector3 input = Quaternion.LookRotation(agent.transform.position.DirectionTo(grapplePoint.value)) * new Vector3(rawInput.x, rawInput.y, 0f);
input = Quaternion.LookRotation(agent.transform.position.DirectionTo(grapplePoint.value)) * (camera.rotation * input);
smoothedInput = Vector3.SmoothDamp(smoothedInput, input, ref smoothedInputRefVelocity, 5f * Time.deltaTime);
// Create the distance variables // Create the distance variables
Vector3 dirToPoint = agent.transform.position.DirectionTo(grapplePoint.value); Vector3 dirToPoint = agent.transform.position.DirectionTo(grapplePoint.value + (smoothedInput * 5));
gizmoHookPoint = grapplePoint.value + (smoothedInput * 5);
float evaluatedSpeed = pullSpeedCurve.value.Evaluate(Mathf.Clamp((Time.time - startTime) / 6f, 0f, Mathf.Infinity)); float evaluatedSpeed = pullSpeedCurve.value.Evaluate(Mathf.Clamp((Time.time - startTime) / 6f, 0f, Mathf.Infinity));
@@ -78,40 +98,30 @@ namespace NodeCanvas.Tasks.Actions {
// Soften the speed changes // Soften the speed changes
currentSpeed = Mathf.Lerp(currentSpeed, speedAgainstCurve, 10f * Time.deltaTime); currentSpeed = Mathf.Lerp(currentSpeed, speedAgainstCurve, 10f * Time.deltaTime);
// Add input changes Debug.Log(dirToPoint);
Vector2 rawInput = agent.GetComponent<PlayerControls>().rawMoveInput;
Vector3 input = Quaternion.LookRotation(dirToPoint) * new Vector3(rawInput.x, rawInput.y, 0f);
smoothedInput = Vector3.SmoothDamp(smoothedInput, input, ref smoothedInputRefVelocity, 30f * Time.deltaTime);
Debug.Log(input);
dirToPoint.y *= 2.5f; dirToPoint.y *= 2.5f;
agent.Move((dirToPoint.normalized + smoothedInput) * currentSpeed * Time.deltaTime); // agent.GetComponent<CharacterController>().Move((dirToPoint.normalized + smoothedInput) * currentSpeed * Time.deltaTime);
agent.AddToCurrentDirection((dirToPoint + smoothedInput), currentSpeed * Time.deltaTime);
// agent.DisableNextMoveCall();
// Debug.Log( $"{ endDeaccelerationCurve.value.Evaluate(((slowdownDistance.value - currentDist)) )}"); // Debug.Log( $"{ endDeaccelerationCurve.value.Evaluate(((slowdownDistance.value - currentDist)) )}");
if (Vector3.Dot(originalDirection, dirToPoint) < breakAtDotProduct) {
MonoManager.current.onLateUpdate -= DrawGrappleGizmo;
EndAction(true);
} else if (currentDist < breakAtDistance) {
MonoManager.current.onLateUpdate -= DrawGrappleGizmo;
EndAction(true);
}
// EndAction(true); // EndAction(true);
} }
public void DrawGrappleGizmo(){ public void DrawGrappleGizmo(){
// Vector3 dirToPoint = agent.transform.position.DirectionTo(grapplePoint.value); using (Draw.WithColor(Color.blue)){
// Draw.SolidCircle(gizmoHookPoint, gizmoHookPoint.DirectionTo(camera.position), 1f);
// using (Draw.WithColor(Color.yellow)){ }
// Draw.Line(agent.transform.position + Vector3.up, grapplePoint.value);
//
// // Draw Gizmo for minimum distance
// Vector3 minLocation = agent.transform.position + (Vector3.up * 1) + (dirToPoint * pullSpeedDistances.value.x);
// Vector3 minToScreen = minLocation.DirectionTo(Camera.main.transform.position);
//
// Draw.SolidCircle(minLocation,minToScreen , .2f);
//
// // Draw Gizmo for minimum distance
// Vector3 maxLocation = agent.transform.position + (Vector3.up * .8f) + (dirToPoint * pullSpeedDistances.value.y);
// Vector3 maxToScreen = maxLocation.DirectionTo(Camera.main.transform.position);
//
// Draw.SolidCircle(maxLocation,maxToScreen , .2f);
// }
} }
//Called when the task is disabled. //Called when the task is disabled.

View File

@@ -4,7 +4,7 @@ MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
defaultReferences: [] defaultReferences: []
executionOrder: 5000 executionOrder: 95
icon: {instanceID: 0} icon: {instanceID: 0}
userData: userData:
assetBundleName: assetBundleName:

View File

@@ -1,7 +1,9 @@
using System; using System;
using NUnit.Framework.Internal;
using UnityEngine; using UnityEngine;
using ParadoxNotion.Design; using ParadoxNotion.Design;
using Sirenix.OdinInspector; using Sirenix.OdinInspector;
using UnityEditor.Rendering;
using UnityEngine.Serialization; using UnityEngine.Serialization;
public enum PlayerFacingDirection{ public enum PlayerFacingDirection{
@@ -71,11 +73,15 @@ namespace Reset.Units{
[ShowInInspector, ReadOnly] private float outputRotationSpeed; [ShowInInspector, ReadOnly] private float outputRotationSpeed;
private float directionChangeDot; private float directionChangeDot;
private bool moveCallDisabledNextFrame;
private CharacterController controller; private CharacterController controller;
private PlayerControls controls; private PlayerControls controls;
private LockOnManager lockOnManager; private LockOnManager lockOnManager;
private Vector3 moveSmooth;
public float gravitySmooth;
[ShowInInspector, PropertyOrder(2)] [ShowInInspector, PropertyOrder(2)]
public UnitMovementData data = new(); public UnitMovementData data = new();
@@ -94,11 +100,14 @@ namespace Reset.Units{
void Update(){ void Update(){
UpdateCurrentDirection(); UpdateCurrentDirection();
UpdateCurrentSpeed();
UpdateCurrentGravity(); UpdateCurrentGravity();
UpdateCurrentSpeed();
UpdateCurrentRotation(); UpdateCurrentRotation();
DoMovement(); DoMovement();
} }
// Add directly to the direction // Add directly to the direction
@@ -184,7 +193,7 @@ namespace Reset.Units{
} }
// Commit move direction // Commit move direction
outputMoveDirection = new Vector3(currentNoY.x, outputMoveDirection.y, currentNoY.z); outputMoveDirection = Vector3.SmoothDamp(outputMoveDirection, new Vector3(currentNoY.x, outputMoveDirection.y, currentNoY.z),ref moveSmooth , .5f *Time.deltaTime);
} }
// Update the speed, called every frame // Update the speed, called every frame
@@ -195,8 +204,8 @@ namespace Reset.Units{
// Update the gravity, called every frame // Update the gravity, called every frame
private void UpdateCurrentGravity(){ private void UpdateCurrentGravity(){
// Accelerate gravity // Accelerate gravity
data.gravityPower += data.gravityAcceleration * Time.deltaTime; // data.gravityPower += data.gravityAcceleration * Time.deltaTime;
data.gravityPower = Mathf.Min(data.gravityPower, data.gravityMax); data.gravityPower = Mathf.Clamp(data.gravityPower, Mathf.NegativeInfinity, data.gravityMax);
// Apply a constant gravity if the player is grounded // Apply a constant gravity if the player is grounded
if (controller.isGrounded) { if (controller.isGrounded) {
@@ -207,7 +216,7 @@ namespace Reset.Units{
float gravityMoveDirection = data.jumpPower + (Physics.gravity.y * data.gravityPower); float gravityMoveDirection = data.jumpPower + (Physics.gravity.y * data.gravityPower);
// Commit gravity to move direction, ignoring XZ since those are done in UpdateMovementDirection // Commit gravity to move direction, ignoring XZ since those are done in UpdateMovementDirection
outputMoveDirection.y = gravityMoveDirection; outputMoveDirection.y = Mathf.SmoothDamp(outputMoveDirection.y, gravityMoveDirection, ref gravitySmooth, .1f * Time.deltaTime);
} }
// Update the rotation, called every frame // Update the rotation, called every frame
@@ -264,9 +273,24 @@ namespace Reset.Units{
public void DoMovement(){ public void DoMovement(){
DoMovement(outputMoveDirection, outputSpeed, data.gravityScale); DoMovement(outputMoveDirection, outputSpeed, data.gravityScale);
} }
public void DisableNextMoveCall(){
moveCallDisabledNextFrame = true;
}
// Custom move from input // Custom move from input
public void DoMovement(Vector3 moveDir, float speed, float gravity){ public void DoMovement(Vector3 moveDir, float speed, float gravityScale, bool relativeToCamera = true){
if (moveCallDisabledNextFrame) {
Vector3 velocity = transform.InverseTransformDirection(controller.velocity.normalized);
outputMoveDirection = new Vector3(velocity.x, outputMoveDirection.y, velocity.z);
moveCallDisabledNextFrame = false;
return;
}
Debug.Log($"moveDir: {moveDir}, agent velocity: {transform.InverseTransformDirection(controller.velocity.normalized)}");
// Seperate the different move directions. Additonal becomes it's own because it needs to be added independently of the other two // Seperate the different move directions. Additonal becomes it's own because it needs to be added independently of the other two
Vector3 moveXZDir = new Vector3(moveDir.x, 0f, moveDir.z); Vector3 moveXZDir = new Vector3(moveDir.x, 0f, moveDir.z);
Vector3 moveYDir = new Vector3(0f, moveDir.y, 0f); Vector3 moveYDir = new Vector3(0f, moveDir.y, 0f);
@@ -274,13 +298,17 @@ namespace Reset.Units{
// Add their related speeds // Add their related speeds
moveXZDir *= speed * Time.deltaTime; moveXZDir *= speed * Time.deltaTime;
moveYDir *= gravity * Time.deltaTime; moveYDir *= gravityScale * Time.deltaTime;
addDir *= additionalSpeed * Time.deltaTime; addDir *= additionalSpeed * Time.deltaTime;
// Construct the direction and move // Construct the direction and move
Vector3 finalDir = moveXZDir + moveYDir; Vector3 finalDir = moveXZDir + moveYDir;
controller.Move((Camera.main.transform.rotation.Flatten(0, null, 0) * finalDir) + addDir); if (relativeToCamera) {
controller.Move((Camera.main.transform.rotation.Flatten(0, null, 0) * finalDir) + addDir);
} else {
controller.Move(finalDir + addDir);
}
} }
void LateUpdate(){ void LateUpdate(){
@@ -308,6 +336,9 @@ namespace Reset.Units{
// float deaccelValue = data.deaccelerationCurve.Evaluate(inputMovement.magnitude); // float deaccelValue = data.deaccelerationCurve.Evaluate(inputMovement.magnitude);
additionalMoveDirection = Vector3.Lerp(additionalMoveDirection, Vector3.zero, data.deaccelerationSmoothing * Time.deltaTime); additionalMoveDirection = Vector3.Lerp(additionalMoveDirection, Vector3.zero, data.deaccelerationSmoothing * Time.deltaTime);
} }
// Decay the gravity
additionalMoveDirection.y -= data.gravityPower;
} }
private void UpdateGravityLate(){ private void UpdateGravityLate(){

View File

@@ -1,2 +1,11 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: b3b4e13d59527d1429a62dde97c6a001 guid: b3b4e13d59527d1429a62dde97c6a001
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 98
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: