46 Commits

Author SHA1 Message Date
Chris
b007dff968 feat: version 1.0 grapple 2025-08-31 13:07:49 -04:00
Chris
9e963784e3 added: rudimentary grapple line renderer 2025-08-31 12:37:57 -04:00
Chris
f87c5a2cb7 change: number tweaks to grapple, some cleanup 2025-08-31 11:58:10 -04:00
Chris
29a608f298 change: clean-up and tweaks to some swinging behavior 2025-08-30 18:10:57 -04:00
Chris
7d1ee7da7d change: rebuilt grapple 2025-08-30 01:08:23 -04:00
Chris
a018b8ba21 change: small graph changes 2025-08-26 21:17:39 -04:00
Chris
06bbc1e87f feat: no longer need to manually create an overlay- attempting to change a value adds it. no longer Vector3 in creator 2025-08-26 21:15:43 -04:00
Chris
46dc94f1f8 change: changing how swing direction is handled 2025-08-26 20:34:08 -04:00
Chris
45a1feb388 change: more grapple work 2025-08-26 14:14:32 -04:00
Chris
99eacd87e5 maint: small scene and project settings changes 2025-08-26 14:13:53 -04:00
Chris
1619c05f2b feat: page locking, external page changing 2025-08-26 14:13:53 -04:00
Chris
4a9e2695f8 refactor: some coloring tweaks 2025-08-26 14:13:53 -04:00
Chris
5050c33df1 maint: removed unused file 2025-08-26 14:13:53 -04:00
Chris
7600a6bb1e feat: controls for pages, better templates, color changing, clear commenting 2025-08-26 14:13:53 -04:00
Chris
2a699019c4 added: debug overlay functional 2025-08-26 14:13:53 -04:00
Chris
af0dde30f2 maint: updated probuilder 6.0.4 to 6.0.6 2025-08-26 14:13:53 -04:00
Chris
a4bb6dabcd added: early platform generation test 2025-08-26 14:13:51 -04:00
Chris
0b3aab8bb4 maint: removed mats i wasn't using 2025-08-26 14:13:50 -04:00
Chris
6184aa3e16 maint: moved sin and sway scripts to world folder 2025-08-26 14:13:50 -04:00
Chris
3f6cb7d3fb added: turned existing structures into prefabs 2025-08-26 14:13:50 -04:00
Chris
b374c960b7 added: a few new large structures 2025-08-26 14:13:47 -04:00
Chris
69718a86f3 changed: environment tag added 2025-08-24 16:16:37 -04:00
Chris
b4590f3bfc changed: redoing grapple again, freshly started 2025-08-23 14:09:13 -04:00
Chris
6de3936897 changed: migrating to new scene for grapple testing, saving this one 2025-08-23 14:07:44 -04:00
Chris
45d55a024e added: new scene for grapple testing 2025-08-23 14:07:27 -04:00
Chris
3e0a6885fb changed: more grapple tweaks and fixes 2025-08-21 22:12:28 -04:00
Chris
a289c78b5d changed: changing some air movement values can now be smoothed (including values that are used to smoothing out inputs) 2025-08-21 17:29:22 -04:00
Chris
93634a9586 changed: tweaks to make grapple feel better 2025-08-17 14:37:33 -04:00
Chris
6e4ab86d51 maint: final tweaks and cleanups 2025-08-14 23:31:29 -04:00
Chris
d4d76a8e89 maint: whitespace nothingburger 2025-08-14 23:31:29 -04:00
Chris
0783545388 maint: deleted old and now unused movement tasks/graphs 2025-08-14 23:31:28 -04:00
Chris
05927d740f maint: removed all old and unused movement tasks 2025-08-14 23:31:28 -04:00
Chris
99247f70f3 changed: movement now also handles opposing inputs. value tweaks. 2025-08-14 23:31:28 -04:00
Chris
4456a36e07 maint: cleaned up some files and tweaked some movement 2025-08-14 23:31:28 -04:00
Chris
e3de32564f changed: graph to use new system 2025-08-14 23:31:28 -04:00
Chris
e80fe66cb8 added: movement settings changing within graph 2025-08-14 23:31:28 -04:00
Chris
3d20741b36 change: moved cameravaluegroups to valuegroup and made for generic usage 2025-08-14 23:31:28 -04:00
Chris
0c3aabaf65 fix: various changes to handler such as gravity speed decoupling, data cloning, rotation smoothing, 2025-08-14 23:31:28 -04:00
Chris
d547942377 fixed: all moving conditions working. removed 'moveFacing' primarily 2025-08-14 23:31:28 -04:00
Chris
b68d8e8dfc fix: rotation in relation to camera no longer broken 2025-08-14 23:31:28 -04:00
Chris
e60091162e changed: UnitMovementHandler.cs is now functional (buggy) 2025-08-14 23:31:28 -04:00
Chris
9f3dec5ae7 change: started unified movement handler 2025-08-14 23:31:28 -04:00
Chris
70453b8117 change: separated all functions of movement into separate tasks 2025-08-14 23:31:27 -04:00
Chris
0e71be73da added: initial seperation of movement from gravity and rotation 2025-08-14 23:31:27 -04:00
Chris
a7006d8dae maint: project settings changes for numbered versions 2025-08-14 23:31:17 -04:00
Chris
19cc3f3adc maint: small scene and project settings changes 2025-08-14 23:31:16 -04:00
23 changed files with 104969 additions and 137 deletions

View File

@@ -1,5 +1,9 @@
fileFormatVersion: 2 fileFormatVersion: 2
<<<<<<<< HEAD:Assets/Map/Materials/StructureMat.mat.meta
guid: eb210d776bd680c4b9a52a7254cf8b81 guid: eb210d776bd680c4b9a52a7254cf8b81
========
guid: 26340c3b8bba95c4396860ccfc2cd444
>>>>>>>> feature/add-player-grapple-launching:Assets/Player/Graphs/PlayerMovementResetTriggerBT.asset.meta
NativeFormatImporter: NativeFormatImporter:
externalObjects: {} externalObjects: {}
mainObjectFileID: 2100000 mainObjectFileID: 2100000

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: dce5b93d5dab8754ba1e190d835dc63c guid: e3074f8f2c7f63f4980f3b22cab464f5
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: fb87f5f35d1ed2644b3e02293ec71bc0 guid: 60be2281fe1b6434183f4b2396cc7cd0
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: c2ae6811bd56a6245a6ab9ec1b0503ae guid: beebc26815c062d4c80362506bb8ad84
NativeFormatImporter: NativeFormatImporter:
externalObjects: {} externalObjects: {}
mainObjectFileID: 11400000 mainObjectFileID: 11400000

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: 296, y: -43}
_zoomFactor: 1 _zoomFactor: 1
_haltSerialization: 0 _haltSerialization: 0
_externalSerializationFile: {fileID: 0} _externalSerializationFile: {fileID: 0}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: f9aba4b029eacea44966829321f0124a guid: 40971083372a2534babfd95df6867650
NativeFormatImporter: NativeFormatImporter:
externalObjects: {} externalObjects: {}
mainObjectFileID: 11400000 mainObjectFileID: 11400000

View File

@@ -0,0 +1,32 @@
%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: PlayerMovementResetTriggerBT
m_EditorClassIdentifier:
_serializedGraph: '{"type":"NodeCanvas.BehaviourTrees.BehaviourTree","nodes":[{"_position":{"x":642.0779,"y":186.1875},"$type":"NodeCanvas.BehaviourTrees.Sequencer","$id":"0"},{"_condition":{"eventName":{"_value":"Delay
Air Movement Reset"},"saveEventValue":{"_name":"_delay"},"$type":"NodeCanvas.Tasks.Conditions.CheckEvent`1[[System.Single,
mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"},"_position":{"x":340.0,"y":408.0},"$type":"NodeCanvas.BehaviourTrees.ConditionNode","$id":"1"},{"policy":1,"dynamic":true,"_position":{"x":840.0,"y":403.0},"$type":"NodeCanvas.BehaviourTrees.Parallel","$id":"2"},{"_condition":{"eventName":{"_value":"Delay
Air Movement Reset"},"saveEventValue":{"_name":"_delay"},"$type":"NodeCanvas.Tasks.Conditions.CheckEvent`1[[System.Single,
mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"},"_position":{"x":592.0,"y":594.0},"$type":"NodeCanvas.BehaviourTrees.Interruptor","$id":"3"},{"_condition":{"timeout":{"_name":"_delay"},"$type":"NodeCanvas.Tasks.Conditions.Timeout"},"_position":{"x":710.0,"y":739.0},"$type":"NodeCanvas.BehaviourTrees.WaitUntil","$id":"4"},{"repeaterMode":1,"repeatTimes":{"_value":1},"_position":{"x":755.0,"y":853.0},"$type":"NodeCanvas.BehaviourTrees.Repeater","$id":"5"},{"_position":{"x":764.0,"y":956.0},"$type":"NodeCanvas.BehaviourTrees.Sequencer","$id":"6"},{"_action":{"eventName":{"_value":"Reset
Air Movement"},"eventValue":{"_value":1.0},"delay":{},"$type":"NodeCanvas.Tasks.Actions.SendEvent`1[[System.Single,
mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"},"_position":{"x":571.0,"y":1106.0},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"7"},{"_condition":{"eventName":{"_value":"Air
Reset Received"},"$type":"NodeCanvas.Tasks.Conditions.CheckEvent"},"_position":{"x":824.0,"y":1105.0},"$type":"NodeCanvas.BehaviourTrees.ConditionNode","$id":"8"},{"_condition":{"eventName":{"_value":"Cancel
Air Movement Reset"},"$type":"NodeCanvas.Tasks.Conditions.CheckEvent"},"_position":{"x":955.4977,"y":595.6238},"$type":"NodeCanvas.BehaviourTrees.ConditionNode","$id":"9"}],"connections":[{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"1"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"2"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"2"},"_targetNode":{"$ref":"3"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"2"},"_targetNode":{"$ref":"9"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"3"},"_targetNode":{"$ref":"4"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"4"},"_targetNode":{"$ref":"5"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"5"},"_targetNode":{"$ref":"6"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"6"},"_targetNode":{"$ref":"7"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"6"},"_targetNode":{"$ref":"8"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"}],"canvasGroups":[],"localBlackboard":{"_variables":{}},"derivedData":{"repeat":true,"$type":"NodeCanvas.BehaviourTrees.BehaviourTree+DerivedSerializationData"}}'
_objectReferences: []
_graphSource:
_version: 3.31
_category:
_comments:
_translation: {x: 216, y: -78}
_zoomFactor: 1
_haltSerialization: 0
_externalSerializationFile: {fileID: 0}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
<<<<<<<< HEAD:Assets/Map/Materials/StructureMat.mat.meta
guid: a15c6b1054c8b5b40ae430307e706008
========
guid: 26340c3b8bba95c4396860ccfc2cd444
>>>>>>>> feature/add-player-grapple-launching:Assets/Player/Graphs/PlayerMovementResetTriggerBT.asset.meta
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 58a4147d2b9083846957575fc3b16667 guid: 9c8da50e4d543dc438c126a404033048
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 8e19eb4aa4fac2a409e792d0d3e5f944 guid: e4ca318d34698fe41ba99a765e54e4c2
NativeFormatImporter: NativeFormatImporter:
externalObjects: {} externalObjects: {}
mainObjectFileID: 11400000 mainObjectFileID: 11400000

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 652c4cc5d47d8de45a54e21abc9d8d1a guid: 94c7611bb3f64b248940847af54844cf
ScriptedImporter: ScriptedImporter:
internalIDToNameTable: [] internalIDToNameTable: []
externalObjects: {} externalObjects: {}

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

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 32f7018093c67004c8595a0f71cc6fb2
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -147,7 +147,7 @@ namespace NodeCanvas.Tasks.Actions {
public void UpdateFloatValue(FloatValueGroup valueGroup, ref CameraSettingSingleValue<float> targetProperty){ public void UpdateFloatValue(FloatValueGroup valueGroup, ref CameraSettingSingleValue<float> targetProperty){
switch (valueGroup.changeValue) { switch (valueGroup.changeValue) {
case ValueChangeAction.NewValue: case ValueChangeAction.NewValue:
targetProperty.targetValue = valueGroup.value; targetProperty.targetValue = valueGroup.value.value;
break; break;
case ValueChangeAction.ResetValue: case ValueChangeAction.ResetValue:
targetProperty.targetValue = targetProperty.originalValue; targetProperty.targetValue = targetProperty.originalValue;

View File

@@ -40,6 +40,7 @@ namespace Reset.Core {
public FloatValueGroup gravityMax = new (newLabel: "Gravity Max"); public FloatValueGroup gravityMax = new (newLabel: "Gravity Max");
public FloatValueGroup gravityAcceleration = new (newLabel: "Gravity Acceleration Speed"); public FloatValueGroup gravityAcceleration = new (newLabel: "Gravity Acceleration Speed");
public FloatValueGroup gravityScale = new (newLabel: "Gravity Scale"); public FloatValueGroup gravityScale = new (newLabel: "Gravity Scale");
public FloatValueGroup settingsChangeSmoothing = new(newLabel: "Settings Change Smoothing");
// Rotation // Rotation
[ParadoxNotion.Design.Header("Rotation")] [ParadoxNotion.Design.Header("Rotation")]
@@ -97,6 +98,7 @@ namespace Reset.Core {
UpdateFloatValue(gravityMax, ref agent.data.gravityMax, ref agent.defaultData.gravityMax); UpdateFloatValue(gravityMax, ref agent.data.gravityMax, ref agent.defaultData.gravityMax);
UpdateFloatValue(gravityAcceleration, ref agent.data.gravityAcceleration, ref agent.defaultData.gravityAcceleration); UpdateFloatValue(gravityAcceleration, ref agent.data.gravityAcceleration, ref agent.defaultData.gravityAcceleration);
UpdateFloatValue(gravityScale, ref agent.data.gravityScale, ref agent.defaultData.gravityScale); UpdateFloatValue(gravityScale, ref agent.data.gravityScale, ref agent.defaultData.gravityScale);
UpdateFloatValue(settingsChangeSmoothing, ref agent.data.settingsChangeSmoothing, ref agent.defaultData.settingsChangeSmoothing);
// Rotation // Rotation
UpdateEnumValue(rotateFacing, ref agent.data.rotateFacing, ref agent.defaultData.rotateFacing); UpdateEnumValue(rotateFacing, ref agent.data.rotateFacing, ref agent.defaultData.rotateFacing);
@@ -222,7 +224,7 @@ namespace Reset.Core {
public void UpdateFloatValue(FloatValueGroup valueGroup, ref float targetProperty, ref float defaultProperty){ public void UpdateFloatValue(FloatValueGroup valueGroup, ref float targetProperty, ref float defaultProperty){
switch (valueGroup.changeValue) { switch (valueGroup.changeValue) {
case ValueChangeAction.NewValue: case ValueChangeAction.NewValue:
targetProperty = valueGroup.value; targetProperty = valueGroup.value.value;
break; break;
case ValueChangeAction.ResetValue: case ValueChangeAction.ResetValue:
targetProperty = defaultProperty; targetProperty = defaultProperty;

View File

@@ -1,7 +1,12 @@
using System;
using Drawing; using Drawing;
using NodeCanvas.Framework; using NodeCanvas.Framework;
using ParadoxNotion.Design; using ParadoxNotion.Design;
using ParadoxNotion.Services; using ParadoxNotion.Services;
using Reset.Core.Tools;
using Reset.Units;
using Sirenix.Serialization;
using Unity.Cinemachine;
using UnityEngine; using UnityEngine;
@@ -9,34 +14,41 @@ 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<float> pullAccelerationSpeed;
public BBParameter<float> pullDeaccelerationSpeed;
[Tooltip("X is minimum speed, Y is maximum speed")] private Vector3 velocityOnStart;
public BBParameter<Vector2> pullTimeRange; private Vector3 directionOnStart;
[Tooltip("X is the distance where the curve will first be evaluated, Y is the distance where the curve will last be evaluated")] private Vector3 originalDirection;
public BBParameter<Vector2> pullSpeedRange; private Vector3 locationOnStart;
public BBParameter<float> slowdownDistance; public float speed;
public float minDistance;
public BBParameter<AnimationCurve> pullSpeedCurve; [Tooltip("The dot product between the current direction to the grapple point, and the direction to the grapple point when started. Starts at 1 and gradually gets closer to -1, with 0 being 90 degrees perpendicular. Only for Y")]
public BBParameter<AnimationCurve> endDeaccelerationCurve; public float horizontalDotBreak;
[Tooltip("The dot product between the current direction to the grapple point, and the direction to the grapple point when started. Starts at 1 and gradually gets closer to -1, with 0 being 90 degrees perpendicular. Only for XZ")]
public float verticalDotBreak;
private float startTime;
private float currentSpeed;
private Vector3 smoothedInput; private Vector3 smoothedInput;
private Vector3 smoothedInputRefVelocity; private Vector3 smoothedInputRefVelocity;
private Vector3 gizmoSwingDirection;
private Vector3 gizmoPointDirection;
private Vector3 gizmoFinalDirection;
private Vector3 gizmosSmoothedInput;
private float gizmoVertValue;
private Transform camera;
//Use for initialization. This is called only once in the lifetime of the task. Vector3 smoothedSwingDirection;
private Vector3 finalDirection;
private float yChangeMultipler;
//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,79 +56,306 @@ 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(){
startTime = Time.time; // Some startup stuff
currentSpeed = pullSpeedCurve.value[0].value * pullSpeedRange.value.y; camera = Camera.main.transform;
MonoManager.current.onLateUpdate += DrawGrappleGizmo;
MonoManager.current.onLateUpdate += UpdateLineRenderer;
// Add the renderer
agent.gameObject.AddComponent<LineRenderer>();
// Set original direction and locoation
locationOnStart = agent.transform.position;
directionOnStart = agent.transform.position.DirectionTo(grapplePoint.value);
// Get the current move direction
velocityOnStart = agent.outputMoveDirection;
// For setting finalDirection's initial value, first compose the swing variables one-time
Vector3 velocityWhenMoving = CalculateSwingDirections(Vector3.Distance(agent.transform.position, grapplePoint.value), directionOnStart);
// Lerp the initial direction more towards the point of the grapple and less towards current momentum if not moving fast
finalDirection = Vector3.Lerp(velocityOnStart, velocityWhenMoving, velocityOnStart.magnitude / 2f); // This isn't working
// Set the intial swing direction to the same thing, so it starts swinging withing snapping on start
smoothedSwingDirection = finalDirection.Flatten(null, .4f, null);
// smoothedInput = agent.GetComponent<CharacterController>().velocity.normalized.Flatten(null, 0f, 0f);
smoothedInput = Vector3.zero;
} }
//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(){
// Create the distance variables agent.outputMoveDirection = Vector3.MoveTowards(agent.outputMoveDirection, Vector3.zero, .5f);
Vector3 dirToPoint = agent.transform.position.DirectionTo(grapplePoint.value);
float evaluatedSpeed = pullSpeedCurve.value.Evaluate(Mathf.Clamp((Time.time - startTime) / 6f, 0f, Mathf.Infinity));
float speedAgainstCurve = Mathf.Lerp(pullSpeedRange.value.x, pullSpeedRange.value.y, evaluatedSpeed);
// Find how far from 0-1 the player is from the max and minimum distance // Basic variables, direction to point and current distnace
// Get the base distance then account for the minimum distance to the point so that being the minimum away will Lerp to 1 Vector3 directionToPoint = agent.transform.position.DirectionTo(grapplePoint.value);
float currentDist = Vector3.Distance(agent.transform.position, grapplePoint.value); float currentDist = Vector3.Distance(agent.transform.position, grapplePoint.value);
// float currentDistMinimumAccounted = (currentDist - pullSpeedDistances.value.x);
// Calculate input
if (currentDist < slowdownDistance.value) { Vector2 rawInput = agent.GetComponent<PlayerControls>().rawMoveInput;
float change = endDeaccelerationCurve.value.Evaluate((slowdownDistance.value - currentDist) / slowdownDistance.value); Vector3 input = new(rawInput.x, rawInput.y, 0f);
speedAgainstCurve = speedAgainstCurve * change;
smoothedInput = Vector3.SmoothDamp(smoothedInput, input, ref smoothedInputRefVelocity, 1f);
DebugOverlayDrawer.ChangeValue("Grapple", "Smoothed Input", smoothedInput.ToString());
// The swing angle needs to change for the downwards swing, based on distance to the ground
Physics.Raycast(agent.transform.position, Vector3.down, out RaycastHit hit);
float distanceToGround = hit.distance;
float downwardsSwingAngle = Mathf.Lerp(5, 100, distanceToGround / 20f);
// Altered swing angle based on distance to the grapple point, used to keep the player not too close or far
float inwardsAngle = Mathf.Lerp(0f, -60f, currentDist / -15f);
float outwardsAngle = Mathf.Lerp(0f, -60f, currentDist / 15f);
float outputAngle = inwardsAngle + outwardsAngle;
DebugOverlayDrawer.ChangeValue("Grapple", "Output Angle", outputAngle.ToString() + $"({inwardsAngle.ToString()} + {outwardsAngle.ToString()})");
// Calculate the swing direction.
// Vector3 swingDirection = Quaternion.LookRotation(smoothedInput) * directionToPoint * smoothedInput.magnitude; // Old
Vector3 pointDirectionXZStable = agent.transform.position.DirectionTo(grapplePoint.value.Flatten(null, agent.transform.position.y));
Vector3 rightSwingDirectin = Quaternion.AngleAxis(100f + outputAngle, Vector3.up) * pointDirectionXZStable; // Working
Vector3 leftSwingDirectin = Quaternion.AngleAxis(-100f - outputAngle, Vector3.up) * pointDirectionXZStable; // Working
Vector3 upwardsSwingDirection = Quaternion.AngleAxis(-140f - outputAngle, Quaternion.LookRotation(directionToPoint) * Vector3.right) * directionToPoint; // Working
Vector3 downwardsSwingDirection = Quaternion.AngleAxis(downwardsSwingAngle, Quaternion.LookRotation(directionOnStart) * Vector3.right) * directionToPoint; // WORKING NOW!! Note: this has to rotate by directionOnStart because else it just moves towards the point
// Get the target swing direction. This is the direction "around" the point based on context
Vector3 targetSwingDirection;
if (Vector3.Dot(-directionOnStart, directionToPoint) > 0) { // More than 90 degrees from the start angle, just start going forward from the swing
targetSwingDirection = finalDirection;
} else {
// Start with up and down
Vector3 yAxisTargetDirection;
// Debug.Log($"prev: {speedAgainstCurve}, norm: {(slowdownDistance.value - currentDist) / slowdownDistance.value}, change: {change}, output: {speedAgainstCurve * change} "); if (Mathf.Abs(input.y) > 0.1f) { // Input exists on up and down, switch direction based on input
yAxisTargetDirection = Vector3.Slerp(upwardsSwingDirection, downwardsSwingDirection, Mathf.Abs((input.y - 1f) / 2f));
} else { // No input on up/down controller, so swing relative to the point
if (directionToPoint.y < 0) { // Since you're under the point swing downwards
yAxisTargetDirection = downwardsSwingDirection;
} else { // Since you're over the point, swing upwards
yAxisTargetDirection = upwardsSwingDirection;
}
}
// Finalize the up and down by setting it based on y input
targetSwingDirection = yAxisTargetDirection * Mathf.Abs((input.y));
// Start doing left and right now
if (Mathf.Abs(input.x) > 0.1f) {
// Pick between swinging left or right
Vector3 xAxisTargetDirection = Vector3.Lerp(rightSwingDirectin, leftSwingDirectin, Mathf.Abs((input.x - 1f) / 2f));
// Add a little guaranteed up swing to the left and right swings
xAxisTargetDirection += (Vector3.up * .1f) * Mathf.Abs((input.x));
// Now finalize the left and right, adding it to the target swing direciton based on x input
targetSwingDirection = Vector3.Slerp(targetSwingDirection, xAxisTargetDirection, Mathf.Abs((input.x)));
}
// Normalize
targetSwingDirection = targetSwingDirection.normalized;
}
// Turn the difference in direction between what's now and what's targetted, to kneecap the smoothing
float newDirDot = Vector3.Dot(smoothedSwingDirection, targetSwingDirection);
// Normalize the dot
newDirDot = (newDirDot + 1f) / 2f;
// Smooth the swinging
smoothedSwingDirection = Vector3.Slerp(smoothedSwingDirection, targetSwingDirection, 2f * Time.deltaTime * newDirDot);
// Set the output direction direction
finalDirection = Vector3.Slerp(finalDirection, smoothedSwingDirection, (elapsedTime / 1f) + Mathf.Max(0f, smoothedInput.magnitude));
// Gizmos
gizmoVertValue = finalDirection.y;
gizmosSmoothedInput = smoothedInput;
gizmoPointDirection = targetSwingDirection;
gizmoSwingDirection = smoothedSwingDirection; // Set to smoothedSwingDirection when done testing
gizmoFinalDirection = finalDirection;
// Finalize the movement to the controller
agent.SetNewDirection(Vector3.Lerp(agent.additionalMoveDirection, finalDirection.Flatten(null, 0), 1f * Time.deltaTime));
agent.SetNewGravity(finalDirection.y);
agent.SmoothToSpeed(speed, 25f * Time.deltaTime);
// Calculate dot products for using to end the action
float xzDot = Vector3.Dot(-directionOnStart.Flatten(null, 0).normalized, -directionToPoint.Flatten(null, 0).normalized);
float yDot = Vector3.Dot( // This one has to be rotated around the XZ
Quaternion.LookRotation(directionToPoint) * -directionOnStart.Flatten(null, null, 0).normalized,
Quaternion.LookRotation(directionToPoint) * -directionToPoint.Flatten(null, null, 0).normalized
);
DebugOverlayDrawer.ChangeValue("Grapple", "Horizontal Dot", xzDot.ToString());
DebugOverlayDrawer.ChangeValue("Grapple", "Vertical Dot", yDot.ToString());
// Check if done
if (xzDot < horizontalDotBreak || yDot < verticalDotBreak) {
if (elapsedTime > 2f){
EndAction(true);
}
} else if (currentDist < minDistance) {
EndAction(true);
}
}
Vector3 CalculateSwingDirections(float currentDist, Vector3 directionToPoint){
// Get input
Vector2 rawInput = agent.GetComponent<PlayerControls>().rawMoveInput;
Vector3 input = new(rawInput.x, rawInput.y, 0f);
// The swing angle needs to change for the downwards swing, based on distance to the ground
Physics.Raycast(agent.transform.position, Vector3.down, out RaycastHit hit);
float distanceToGround = hit.distance;
float downwardsSwingAngle = Mathf.Lerp(30, 100, distanceToGround / 20f);
// Altered swing angle based on distance to the grapple point, used to keep the player not too close or far
float inwardsAngle = Mathf.Lerp(0f, -60f, currentDist / -15f);
float outwardsAngle = Mathf.Lerp(0f, -60f, currentDist / 15f);
float outputAngle = inwardsAngle + outwardsAngle;
DebugOverlayDrawer.ChangeValue("Grapple", "Output Angle", outputAngle.ToString() + $"({inwardsAngle.ToString()} + {outwardsAngle.ToString()})");
Vector3 pointDirectionXZStable = agent.transform.position.DirectionTo(grapplePoint.value.Flatten(null, agent.transform.position.y));
Vector3 rightSwingDirectin = Quaternion.AngleAxis(100f + outputAngle, Vector3.up) * pointDirectionXZStable; // Working
Vector3 leftSwingDirectin = Quaternion.AngleAxis(-100f - outputAngle, Vector3.up) * pointDirectionXZStable; // Working
Vector3 upwardsSwingDirection = Quaternion.AngleAxis(-140f - outputAngle, Quaternion.LookRotation(directionToPoint) * Vector3.right) * directionToPoint; // Working
Vector3 downwardsSwingDirection = Quaternion.AngleAxis(downwardsSwingAngle, Quaternion.LookRotation(directionOnStart) * Vector3.right) * directionToPoint; // WORKING NOW!! Note: this has to rotate by directionOnStart because else it just moves towards the point
// Get the target swing direction. This is the direction "around" the point based on context
Vector3 targetSwingDirection;
// Start with up and down
Vector3 yAxisTargetDirection;
if (Mathf.Abs(input.y) > 0.1f) { // Input exists on up and down, switch direction based on input
yAxisTargetDirection = Vector3.Slerp(upwardsSwingDirection, downwardsSwingDirection, Mathf.Abs((input.y - 1f) / 2f));
} else { // No input on up/down controller, so swing relative to the point
if (directionToPoint.y < 0) { // Since you're under the point swing downwards
yAxisTargetDirection = downwardsSwingDirection;
} else { // Since you're over the point, swing upwards
yAxisTargetDirection = downwardsSwingDirection;
}
} }
// Evaluate the normalized value if (directionToPoint.y > -.5f) {
// float normaled = Mathf.Lerp(0, 1f, 1f - elapsedTime / (pullSpeedDistances.value.y - pullSpeedDistances.value.x)); // yAxisTargetDirection += Vector3.up * 4f; // This works but it's making downward motion not work
}
// Use the curve evaluation to set the speed targetSwingDirection = yAxisTargetDirection * Mathf.Abs((input.y));
// float outputSpeed = Mathf.Lerp(pullTimeRange.value.x, pullTimeRange.value.y, evaluatedSpeed);
// Soften the speed changes
currentSpeed = Mathf.Lerp(currentSpeed, speedAgainstCurve, 10f * Time.deltaTime);
// Add input changes if (Mathf.Abs(input.x) > 0.1f) {
Vector2 rawInput = agent.GetComponent<PlayerControls>().rawMoveInput; Vector3 xAxisTargetDirection = Vector3.Lerp(rightSwingDirectin, leftSwingDirectin, Mathf.Abs((input.x - 1f) / 2f));
Vector3 input = Quaternion.LookRotation(dirToPoint) * new Vector3(rawInput.x, rawInput.y, 0f); targetSwingDirection = Vector3.Slerp(targetSwingDirection, xAxisTargetDirection, Mathf.Abs((input.x)));
// targetSwingDirection = xAxisTargetDirection;
smoothedInput = Vector3.SmoothDamp(smoothedInput, input, ref smoothedInputRefVelocity, 30f * Time.deltaTime); DebugOverlayDrawer.ChangeValue("Grapple", "LR Input Dot", Mathf.Abs((input.x - 1f) / 2f).ToString());
}
Debug.Log(input); return targetSwingDirection.normalized;
}
dirToPoint.y *= 2.5f; public void UpdateLineRenderer(){
// Update the Line Renderer
var lr = agent.GetComponent<LineRenderer>();
agent.Move((dirToPoint.normalized + smoothedInput) * currentSpeed * Time.deltaTime); lr.positionCount = 2;
// Debug.Log( $"{ endDeaccelerationCurve.value.Evaluate(((slowdownDistance.value - currentDist)) )}");
// Very shoddy position setting
lr.SetPositions(new []{
agent.transform.position,
grapplePoint.value}
);
lr.startWidth = .1f;
lr.endWidth = .1f;
// EndAction(true);
} }
public void DrawGrappleGizmo(){ public void DrawGrappleGizmo(){
// Vector3 dirToPoint = agent.transform.position.DirectionTo(grapplePoint.value); // Destination gizmos
// using (Draw.WithColor(Color.blue)){
// using (Draw.WithColor(Color.yellow)){ Vector3 offsetTowardsCamera = grapplePoint.value.DirectionTo(camera.transform.position);
// Draw.Line(agent.transform.position + Vector3.up, grapplePoint.value);
// // Grapple Point
// // Draw Gizmo for minimum distance Draw.SolidCircle(grapplePoint.value + offsetTowardsCamera, grapplePoint.value.DirectionTo(camera.transform.position), .4f);
// Vector3 minLocation = agent.transform.position + (Vector3.up * 1) + (dirToPoint * pullSpeedDistances.value.x); Draw.Label2D(grapplePoint.value + offsetTowardsCamera * 2f + Vector3.up, "Grapple Point");
// Vector3 minToScreen = minLocation.DirectionTo(Camera.main.transform.position);
// using (Draw.WithLineWidth(1.5f)) {
// Draw.SolidCircle(minLocation,minToScreen , .2f); // Final Direction
// Draw.Line(agent.transform.position + Vector3.up, agent.transform.position + Vector3.up + gizmoFinalDirection.normalized * 2f);
// // Draw Gizmo for minimum distance Draw.ArrowheadArc(agent.transform.position + Vector3.up, gizmoFinalDirection.normalized, 2f, 15f);
// Vector3 maxLocation = agent.transform.position + (Vector3.up * .8f) + (dirToPoint * pullSpeedDistances.value.y);
// Vector3 maxToScreen = maxLocation.DirectionTo(Camera.main.transform.position); // Colors for faded arrows
// Color swingColor = Color.Lerp(Color.blue, Color.blue.Alpha(.4f), (elapsedTime * .6f));
// Draw.SolidCircle(maxLocation,maxToScreen , .2f); Color dirColor = Color.Lerp(Color.blue.Alpha(.4f), Color.blue, (elapsedTime * .6f));
// }
// Swing Direction
using (Draw.WithColor(swingColor)) {
float swingLength = 2.2f;
Vector3 swingStart = agent.transform.position + Vector3.up * .4f;
Vector3 swingDir = swingStart + gizmoSwingDirection.normalized * swingLength;
Draw.DashedLine(swingStart, swingDir, .2f, .2f);
Draw.ArrowheadArc(swingStart, gizmoSwingDirection.normalized, swingLength, 15f);
Draw.Label2D(swingDir + Vector3.up * .4f, "Swing Direction");
}
// Point Direction
using (Draw.WithColor(dirColor)) {
float pointLength = 1.2f;
Vector3 pointStart = agent.transform.position + Vector3.up * .2f;
Vector3 pointDir = grapplePoint.value;
Draw.DashedLine(pointStart, pointDir, .2f, .2f);
Draw.ArrowheadArc(pointStart, gizmoPointDirection.normalized, pointLength, 15f);
Draw.Label2D(pointDir + Vector3.up * .4f, "Grapple Point Direction");
}
}
}
// Input Gizmos
using (Draw.WithColor(Color.red)) {
// Input left and right, up and down for size
Vector3 inputGizmoOffset = (agent.transform.position + camera.rotation * Vector3.back + Vector3.up * .5f);
Vector3 inputGizmoPosition = inputGizmoOffset + camera.rotation * Vector3.Lerp(Vector3.left, Vector3.right, (gizmosSmoothedInput.x - 1 ) / 2f + 1f);
Draw.Line(inputGizmoOffset + camera.rotation * Vector3.left, inputGizmoOffset + camera.rotation * Vector3.right);
Draw.SolidCircle(inputGizmoPosition, inputGizmoPosition.DirectionTo(camera.position), Mathf.Lerp(.2f, .6f, (gizmosSmoothedInput.y - 1 ) / 2f + 1f));
}
// Up and down
using (Draw.WithColor(Color.yellow)) {
Vector3 vertGizmoPosition = agent.transform.position + camera.rotation * Vector3.left;
float vertGizmoHeight = 1.75f;
Vector3 vertGizmoStart = vertGizmoPosition + Vector3.up * vertGizmoHeight;
Vector3 vertGizmoEnd = vertGizmoPosition + Vector3.up * .35f;
Vector3 circlePos = Vector3.Lerp(vertGizmoEnd, vertGizmoStart, gizmoVertValue);
Draw.Line(vertGizmoStart, vertGizmoEnd);
Draw.SolidCircle(circlePos, circlePos.DirectionTo(camera.position), .4f);
Draw.Label2D(vertGizmoStart + camera.rotation * Vector3.left * 1.5f, gizmoVertValue.ToString());
Vector3 vertArrowUpPosition = vertGizmoStart + camera.rotation * Vector3.left * 1f + Vector3.up * .2f;
Vector3 vertArrowDownPosition = vertGizmoStart + camera.rotation * Vector3.left * 1f + Vector3.down * .2f;
if (gizmoVertValue > 0) {
Draw.SolidTriangle(vertArrowUpPosition + camera.rotation * Vector3.left/4, vertArrowUpPosition + Vector3.up/2, vertArrowUpPosition + camera.rotation * Vector3.right/4);
} else {
Draw.SolidTriangle(vertArrowDownPosition + camera.rotation * Vector3.left/4, vertArrowDownPosition + Vector3.down/2, vertArrowDownPosition + camera.rotation * Vector3.right/4);
}
}
} }
//Called when the task is disabled. //Called when the task is disabled.
protected override void OnStop() { protected override void OnStop() {
MonoManager.current.onLateUpdate -= DrawGrappleGizmo;
MonoManager.current.onLateUpdate -= UpdateLineRenderer;
GameObject.Destroy(agent.gameObject.GetComponent<LineRenderer>());
} }
//Called when the task is paused. //Called when the task is paused.

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,4 +1,10 @@
using System; using System;
#if UNITY_EDITOR
using NodeCanvas.Editor;
#endif
using NodeCanvas.Framework;
using ParadoxNotion.Design; using ParadoxNotion.Design;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
@@ -97,13 +103,14 @@ namespace Reset.Core{
public struct FloatValueGroup{ public struct FloatValueGroup{
public string label; public string label;
public float value; // public float value;
public BBParameter<float> value;
public ValueChangeAction changeValue; public ValueChangeAction changeValue;
public FloatValueGroup(string newLabel){ public FloatValueGroup(string newLabel){
label = newLabel; label = newLabel;
value = 0f; value = new BBParameter<float>().value = 0f;
changeValue = ValueChangeAction.NoChange; changeValue = ValueChangeAction.NoChange;
} }
} }
@@ -123,7 +130,7 @@ namespace Reset.Core{
#if UNITY_EDITOR #if UNITY_EDITOR
public class BoolValueGroupDrawer : ObjectDrawer<BoolValueGroup> { public class BoolValueGroupDrawer : ObjectDrawer<BoolValueGroup> {
public override BoolValueGroup OnGUI(GUIContent content, BoolValueGroup _instance){ public override BoolValueGroup OnGUI(GUIContent _content, BoolValueGroup _instance){
// Remove label for floats // Remove label for floats
EditorGUIUtility.labelWidth = 50; EditorGUIUtility.labelWidth = 50;
@@ -274,9 +281,11 @@ namespace Reset.Core{
// Create the x settings enum // Create the x settings enum
_instance.changeValue = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeValue); _instance.changeValue = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeValue);
// Create the value/disabled information field // Create the value/disabled information field
if (_instance.changeValue == ValueChangeAction.NewValue){ if (_instance.changeValue == ValueChangeAction.NewValue){
_instance.value = EditorGUILayout.FloatField(_instance.value, floatOptions); // _instance.value = EditorGUILayout.FloatField(_instance.value, floatOptions);
BBParameterEditor.ParameterField("", _instance.value);
} else { } else {
EditorGUI.BeginDisabledGroup(true); EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.TextField(_instance.changeValue == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions); EditorGUILayout.TextField(_instance.changeValue == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);

View File

@@ -1,8 +1,10 @@
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 UnityEngine.Serialization; using UnityEngine.Serialization;
using Quaternion = UnityEngine.Quaternion;
public enum PlayerFacingDirection{ public enum PlayerFacingDirection{
TowardsTarget = 0, TowardsTarget = 0,
@@ -42,6 +44,7 @@ namespace Reset.Units{
public float gravityMax = 8f; public float gravityMax = 8f;
public float gravityAcceleration = 1f; public float gravityAcceleration = 1f;
public float gravityScale = 1f; public float gravityScale = 1f;
public float settingsChangeSmoothing = 6f;
// Rotation // Rotation
[ShowInInspector, SerializeReference] [ShowInInspector, SerializeReference]
@@ -61,21 +64,35 @@ namespace Reset.Units{
// public float value; // public float value;
// } // }
// Debug viewing //
[ShowInInspector, ReadOnly] private float outputSpeed; [FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] private float outputSpeed;
[ShowInInspector, ReadOnly] private float additionalSpeed; [FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] private float additionalSpeed;
[ShowInInspector, ReadOnly] public Vector3 outputMoveDirection; [FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] public Vector3 outputMoveDirection;
[ShowInInspector, ReadOnly] private Vector3 additionalMoveDirection; [FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] public Vector3 additionalMoveDirection;
[ShowInInspector, ReadOnly] private Quaternion outputRotation; [FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] private Quaternion outputRotation;
[ShowInInspector, ReadOnly] private Quaternion specifiedRotation; [FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] private Quaternion specifiedRotation;
[ShowInInspector, ReadOnly] private float outputRotationSpeed; [FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] private float outputRotationSpeed;
// Used by graph to gradually shift into new values rather than dump them. Even if they're smoothed values they need to be eased into
[FoldoutGroup("Smoothed Values"), ShowInInspector, ReadOnly] private float smoothedJumpDecay;
[FoldoutGroup("Smoothed Values"), ShowInInspector, ReadOnly] private float smoothedGravityAccel;
[FoldoutGroup("Smoothed Values"), ShowInInspector, ReadOnly] private float smoothedGravityScale;
[FoldoutGroup("Smoothed Values"), ShowInInspector, ReadOnly] private float settingsChangeRotationSpeed;
private float directionChangeDot; private float directionChangeDot;
private bool moveCallDisabledNextFrame;
private bool movedThisFrame;
private CharacterController controller; private CharacterController controller;
private PlayerControls controls; private PlayerControls controls;
private LockOnManager lockOnManager; private LockOnManager lockOnManager;
private Vector3 moveSmooth;
public float gravitySmooth;
private bool relativeToCamera;
[ShowInInspector, PropertyOrder(2)] [ShowInInspector, PropertyOrder(2)]
public UnitMovementData data = new(); public UnitMovementData data = new();
@@ -94,8 +111,9 @@ namespace Reset.Units{
void Update(){ void Update(){
UpdateCurrentDirection(); UpdateCurrentDirection();
UpdateCurrentSpeed();
UpdateCurrentGravity(); UpdateCurrentGravity();
UpdateCurrentSpeed();
UpdateCurrentRotation(); UpdateCurrentRotation();
DoMovement(); DoMovement();
@@ -106,6 +124,18 @@ namespace Reset.Units{
additionalMoveDirection += inputDirection.normalized; additionalMoveDirection += inputDirection.normalized;
additionalSpeed = power; additionalSpeed = power;
} }
public void SmoothToSpeed(float desiredSpeed, float smoothing){
additionalSpeed = Mathf.Lerp(additionalSpeed, desiredSpeed, smoothing * Time.deltaTime);
}
public void SetNewDirection(Vector3 inputDirection){ // NOTE: If smoothing desired add a default bool for smoothing maybe?
additionalMoveDirection = inputDirection.Flatten(null, 0f, null);
}
public void SetNewGravity(float value){
additionalMoveDirection.y = value;
}
// Hold a new rotation to be moved to during PlayerFacingDirection.SpecifiedRotation // Hold a new rotation to be moved to during PlayerFacingDirection.SpecifiedRotation
public void SetSpecifiedRotation(Quaternion inputRotation){ public void SetSpecifiedRotation(Quaternion inputRotation){
@@ -130,7 +160,7 @@ namespace Reset.Units{
if (float.IsPositiveInfinity(speed)) { if (float.IsPositiveInfinity(speed)) {
return; return;
} }
outputSpeed = Mathf.Lerp(outputSpeed, Mathf.Max(data.moveSpeed, speed), priority); outputSpeed = Mathf.Lerp(outputSpeed, Mathf.Max(data.moveSpeed, speed), priority);
} }
@@ -162,7 +192,6 @@ namespace Reset.Units{
// Smooth movement. Use deaccel smoothing if the input magnitude is lower, and accel smoothing if it's higher // Smooth movement. Use deaccel smoothing if the input magnitude is lower, and accel smoothing if it's higher
// Also checks when grounded to only use Slerp on the ground // Also checks when grounded to only use Slerp on the ground
if (targetNoY.magnitude > currentNoY.magnitude) { if (targetNoY.magnitude > currentNoY.magnitude) {
if (controller.isGrounded){ if (controller.isGrounded){
slerpedValue = Vector3.Slerp(currentNoY, targetNoY, data.accelerationSmoothing * Time.deltaTime); slerpedValue = Vector3.Slerp(currentNoY, targetNoY, data.accelerationSmoothing * Time.deltaTime);
@@ -184,19 +213,20 @@ 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
private void UpdateCurrentSpeed(){ private void UpdateCurrentSpeed(){
Debug.Log(data.moveSpeed);
outputSpeed = Mathf.Lerp(outputSpeed, data.moveSpeed, data.moveSpeedSoothing * Time.deltaTime); outputSpeed = Mathf.Lerp(outputSpeed, data.moveSpeed, data.moveSpeedSoothing * Time.deltaTime);
} }
// 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 += smoothedGravityAccel * 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 +237,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
@@ -254,7 +284,7 @@ namespace Reset.Units{
} }
// Calculate rotation speed, as in how fast the fella rotates. This value has it's own smoothing to allow for gradual increasing/decreasing of the speed till it reaches the target // Calculate rotation speed, as in how fast the fella rotates. This value has it's own smoothing to allow for gradual increasing/decreasing of the speed till it reaches the target
outputRotationSpeed = Mathf.Lerp(outputRotationSpeed, data.rotationSpeed, data.rotationSmoothing * Time.deltaTime); outputRotationSpeed = Mathf.Lerp(outputRotationSpeed, data.rotationSpeed, settingsChangeRotationSpeed * Time.deltaTime);
// Set final rotation // Set final rotation
transform.rotation = Quaternion.Slerp(transform.rotation, outputRotation, outputRotationSpeed * Time.deltaTime).Flatten(0, null, 0); transform.rotation = Quaternion.Slerp(transform.rotation, outputRotation, outputRotationSpeed * Time.deltaTime).Flatten(0, null, 0);
@@ -264,9 +294,15 @@ 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){
// 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,18 +310,25 @@ namespace Reset.Units{
// Add their related speeds // Add their related speeds
moveXZDir *= speed * Time.deltaTime; moveXZDir *= speed * Time.deltaTime;
moveYDir *= gravity * Time.deltaTime; moveYDir *= smoothedGravityScale * 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);
controller.Move((Camera.main.transform.rotation.Flatten(0, null, 0) * finalDir) + addDir);
} }
void LateUpdate(){ void LateUpdate(){
UpdateGravityLate(); UpdateGravityLate();
DecayAdditionalDirection(); DecayAdditionalDirection();
SmoothingSettingsChanges();
}
private void SmoothingSettingsChanges(){
smoothedJumpDecay = Mathf.Lerp(smoothedJumpDecay, data.jumpPowerDecay, data.settingsChangeSmoothing * Time.deltaTime);
smoothedGravityAccel = Mathf.Lerp(smoothedGravityAccel, data.gravityAcceleration, data.settingsChangeSmoothing * Time.deltaTime);
smoothedGravityScale = Mathf.Lerp(smoothedGravityScale, data.gravityScale, data.settingsChangeSmoothing * Time.deltaTime);
settingsChangeRotationSpeed = Mathf.Lerp(settingsChangeRotationSpeed, data.rotationSpeed, data.settingsChangeSmoothing * Time.deltaTime);
} }
void DecayAdditionalDirection(){ void DecayAdditionalDirection(){
@@ -303,16 +346,19 @@ namespace Reset.Units{
// Decay the direction // Decay the direction
if (inputMovement.magnitude < currentNoY.magnitude) { if (inputMovement.magnitude < currentNoY.magnitude) {
additionalMoveDirection = Vector3.Slerp(additionalMoveDirection, Vector3.zero,data.accelerationSmoothing * Time.deltaTime); additionalMoveDirection = Vector3.Slerp(additionalMoveDirection, Vector3.zero,data.accelerationSmoothing * Time.deltaTime);
} else { } else {
// 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;
additionalMoveDirection.y = Mathf.Max(0f, additionalMoveDirection.y);
} }
private void UpdateGravityLate(){ private void UpdateGravityLate(){
// Decay jump power // Decay jump power
data.jumpPower -= data.jumpPowerDecay * Time.deltaTime; data.jumpPower -= smoothedJumpDecay * Time.deltaTime;
data.jumpPower = Mathf.Max(0f, data.jumpPower); data.jumpPower = Mathf.Max(0f, data.jumpPower);
} }
} }

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:

View File

@@ -9,6 +9,6 @@ EditorBuildSettings:
path: Assets/Scenes/SampleScene.unity path: Assets/Scenes/SampleScene.unity
guid: 99c9720ab356a0642a771bea13969a05 guid: 99c9720ab356a0642a771bea13969a05
m_configObjects: m_configObjects:
com.unity.input.settings: {fileID: 11400000, guid: 8e19eb4aa4fac2a409e792d0d3e5f944, type: 2} com.unity.input.settings: {fileID: 11400000, guid: e4ca318d34698fe41ba99a765e54e4c2, type: 2}
com.unity.input.settings.actions: {fileID: -944628639613478452, guid: 052faaac586de48259a63d0c4782560b, type: 3} com.unity.input.settings.actions: {fileID: -944628639613478452, guid: 94c7611bb3f64b248940847af54844cf, type: 3}
m_UseUCBPForAssetBundles: 0 m_UseUCBPForAssetBundles: 0