maint: deleted old and now unused movement tasks/graphs

This commit is contained in:
Chris
2025-08-14 21:58:58 -04:00
parent 6ba17a4373
commit a60179205c
16 changed files with 0 additions and 623 deletions

View File

@@ -1,121 +0,0 @@
using System;
using System.Linq;
using NodeCanvas.Framework;
using ParadoxNotion;
using ParadoxNotion.Design;
using UnityEngine;
using UnityEngine.InputSystem;
using Reset.Player.Movement;
namespace NodeCanvas.Tasks.Actions {
[Category("Reset/Movement")]
public class AddJump : ActionTask<CharacterController> {
public BBParameter<Vector3> airMoveDirection;
public BBParameter<float> jumpPower;
[Space(5)]
public BBParameter<float> jumpStrength;
[SliderField(0, 1)]
public BBParameter<float> standStillJumpStrength;
[Tooltip("Determines how much current movement vectors into jump direction")]
[SliderField(0, 1)]
public BBParameter<float> currentVelocityInheritence;
public BBParameter<Vector3> directionalForce;
[SliderField(0, 1)]
public BBParameter<float> directionalForceStrength;
protected override string info {
get{
string dirStrength = "";
if (directionalForce.value != Vector3.zero && directionalForceStrength.value > 0f) {
dirStrength = $", towards <i>{directionalForce.value}</i> * {directionalForceStrength.value}";
}
return string.Format($"<b>Start Jump</b>, <i>{jumpStrength.value}</i> strength" + dirStrength);
}
}
//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(){
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(){
// Set jump power
jumpPower.value = jumpStrength.value;
// Save current velocity and get current input direction
Vector3 currentVelocityVector3 = new Vector3(agent.velocity.x, 0f, agent.velocity.z);
Vector2 currentInput = agent.GetComponent<PlayerControls>().rawMoveInput;
Vector3 currentInputVector3 = new Vector3(currentInput.x, 0f, currentInput.y);
// Ignore rotation for the current velocity
Vector3 currentVelocityWorld = agent.transform.InverseTransformDirection(currentVelocityVector3.normalized);
// Get the dot product between current velocity's direction and current input (UNUSED FOR NOW)
float velocityInputDot = Vector3.Dot(currentVelocityWorld, currentInputVector3);
// Set air move direction
if (agent.isGrounded) {
airMoveDirection.value = currentVelocityVector3;
} else {
// Hold new desired air direction and Dot against the existing air moving directioin
Vector3 desiredAirMoveDirection = currentInputVector3;
float airMoveDirectionDot = Vector3.Dot(desiredAirMoveDirection.normalized, airMoveDirection.value.normalized);
// Check threshold of current XZ velocity- if it's too close to zero, use the jumpStrength for jumping velocity. If it's not, use the current velocity
float velocityThreshold = 4f;
float magnitudeZeroDifference = Mathf.Clamp(currentVelocityVector3.magnitude - velocityThreshold, 0f, Mathf.Infinity) / velocityThreshold; // Divided by maximum to return a 0-1 value. Clamping not required.
float outputHoritontalVelocity = Mathf.Lerp(jumpStrength.value, currentVelocityVector3.magnitude, Math.Clamp(magnitudeZeroDifference, 0f, 1f));
outputHoritontalVelocity = Mathf.Min(outputHoritontalVelocity, Mathf.Lerp(standStillJumpStrength.value * jumpStrength.value, jumpStrength.value * .4f, magnitudeZeroDifference));
// Do the same for directional jump strength
outputHoritontalVelocity = Mathf.Lerp(outputHoritontalVelocity, jumpStrength.value, directionalForceStrength.value);
// Remap the dot to set -1 (opposing direction) to -.5f, and 1 (same direciton) to 1.2f
// This is done to allow some sideways jumping direction change, but none backwards, and all forwards
float remappedAirDirectionDot = Mathf.Lerp(.1f, 1.2f, airMoveDirectionDot);
remappedAirDirectionDot = Mathf.Clamp(remappedAirDirectionDot, 0f, 1f);
// Lerp between the current direction and the inputted direction based on the previous dot product
Vector3 outputDirection = Vector3.Lerp(currentInputVector3.normalized, currentVelocityVector3.normalized, remappedAirDirectionDot);
// If there is a directional force (such as the Wall Climb jump going straight upward) supplied in the task, lean into that based on it's strength
outputDirection = Vector3.Lerp(outputDirection, directionalForce.value.normalized, directionalForceStrength.value).normalized;
// Extra math to degrade current air move direction by velocity inheritence, before applying new air direction
airMoveDirection.value *= currentVelocityInheritence.value;
// Account for the camera's rotation before setting it as the air move direction
outputDirection = Camera.main.transform.rotation.Flatten(0, null, 0) * outputDirection;
// Set air move direction
airMoveDirection.value += outputDirection * outputHoritontalVelocity;
}
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() {
}
}
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 86e5b037e41d5bb4b8805890ee72ad29

View File

@@ -1,56 +0,0 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
using Reset.Player.Movement;
namespace NodeCanvas.Tasks.Actions {
[Category("Reset/Movement")]
public class CalculateAirMovement : ActionTask<Transform>{
public BBParameter<Vector3> airMoveDirection;
public BBParameter<Vector3> groundMoveDirection; // Unused on 7/29/25, delete if still unusued later
private float airControlPower = 1f;
//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() {
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(){
airControlPower = 1f;
}
//Called once per frame while the action is active.
protected override void OnUpdate() {
// Decay Current Air Movement
airMoveDirection.value = Vector3.Lerp(airMoveDirection.value, Vector3.zero, .7f * Time.deltaTime);
// Decay Air Control power
airControlPower = Mathf.Lerp(airControlPower, 0f, 2f * Time.deltaTime);
// Add air control
Vector3 inputVector3 = new(agent.GetComponent<PlayerControls>().rawMoveInput.x, 0f, agent.GetComponent<PlayerControls>().rawMoveInput.y);
float originalMagnitude = airMoveDirection.value.magnitude;
airMoveDirection.value += Camera.main.transform.rotation.Flatten(0, null, 0) *
inputVector3 * airControlPower;
airMoveDirection.value = Vector3.ClampMagnitude(airMoveDirection.value, originalMagnitude);
}
//Called when the task is disabled.
protected override void OnStop() {
// groundMoveDirection.value = agent.GetComponent<CharacterController>().velocity;
EndAction(true);
}
//Called when the task is paused.
protected override void OnPause() {
}
}
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 38d61a72cc7757448b3db6c04395cf91

View File

@@ -1,78 +0,0 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Actions {
[Category("Reset/Movement")]
[Description("Unit flat ground movement")]
public class CalculateGroundedLocomotion : ActionTask<CharacterController>{
public BBParameter<float> moveSpeed;
public BBParameter<Vector3> moveDirection;
protected override string info {
get{
return string.Format($"<b>Set ground movement</b>, <i>{moveSpeed.value}</i> speed");
}
}
private float sprintPower;
private bool sprinting;
//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() {
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() {
}
//Called once per frame while the action is active.
protected override void OnUpdate() {
// Get current input direction
Vector3 flatSurfaceDirection = Vector3.zero;
if (agent.isGrounded) {
Vector2 rawInput = agent.transform.GetComponent<PlayerControls>().rawMoveInput;
flatSurfaceDirection = new(rawInput.x, 0, rawInput.y);
}
float CalculateSpeed(){
// Calculate sprinting speed
float outputSpeed = 0f;
// Add base speed
outputSpeed += moveSpeed.value;
return outputSpeed;
}
// Rotate input to forward direction for flat surface
// flatSurfaceDirection = agent.transform.rotation * flatSurfaceDirection;
// Finalize flat surface direction by adding speed
flatSurfaceDirection *= CalculateSpeed();
moveDirection.value = flatSurfaceDirection;
EndAction(true);
}
//Called when the task is disabled.
protected override void OnStop() {
}
//Called when the task is paused.
protected override void OnPause() {
}
}
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 808dc54c4ce75e846890125a4f87e516

View File

@@ -1,121 +0,0 @@
using System;
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using ParadoxNotion.Serialization.FullSerializer;
using Sirenix.OdinInspector;
using UnityEngine;
namespace NodeCanvas.Tasks.Actions {
[Category("Reset")]
[Description("Update the agent's position and rotation (scale too, sure whynot) either instantly or over time.")]
public class ChangeAgentTransform : ActionTask<CharacterController>{
public enum TransformProperty{
Position,
Rotation,
Scale
}
protected override string info {
get{
string basicText = string.Format($"Player {targetProperty.ToString()} to {(targetValue.isPresumedDynamic ? targetValue.name : targetValue.value)}");
basicText += relativeToSelf.value ? ", relative to Self" : "";
return basicText;
}
}
public TransformProperty targetProperty;
[ParadoxNotion.Design.ShowIf("targetProperty", 1), Space(5)]
public BBParameter<bool> forcePositionChange;
public BBParameter<Vector3> targetValue;
public BBParameter<bool> relativeToSelf;
[Tooltip("Set this to the current position if you're trying to rotate by 'this much'. Keep it zero for world space values.")]
public BBParameter<Vector3> relativeValue;
public BBParameter<bool> changeInstantly;
public BBParameter<float> smoothing;
private Vector3 currentVel;
//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() {
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 (targetProperty) {
case TransformProperty.Position:
Vector3 relativeUseValue = relativeValue.value;
if (relativeToSelf.value) {
relativeUseValue = agent.transform.position;
}
if (changeInstantly.value) {
agent.Move(agent.transform.position.DirectionTo(relativeUseValue + targetValue.value));
}
break;
case TransformProperty.Rotation:
agent.transform.rotation = Quaternion.LookRotation(relativeValue.value) * Quaternion.Euler(targetValue.value);
break;
case TransformProperty.Scale:
break;
default:
throw new ArgumentOutOfRangeException();
}
if (changeInstantly.value) {
EndAction(true);
}
}
//Called once per frame while the action is active.
protected override void OnUpdate() {
switch (targetProperty) {
case TransformProperty.Position:
Vector3 relativeUseValue = relativeValue.value;
if (relativeToSelf.value) {
relativeUseValue = agent.transform.position;
}
if (!changeInstantly.value) {
Vector3 targetPosition = relativeUseValue + targetValue.value;
// agent.transform.position = Vector3.SmoothDamp(agent.transform.position, targetPosition,
// ref currentVel, smoothing.value * Time.deltaTime);
agent.Move((agent.transform.position.DirectionTo(targetPosition)).normalized * .5f * Mathf.Lerp(0, 1, Vector3.Distance(agent.transform.position, targetPosition)) * smoothing.value * Time.deltaTime);
EndAction();
}
break;
case TransformProperty.Rotation:
agent.transform.rotation = Quaternion.Euler(relativeValue.value) * Quaternion.Euler(targetValue.value);
break;
case TransformProperty.Scale:
break;
default:
throw new ArgumentOutOfRangeException();
}
}
//Called when the task is disabled.
protected override void OnStop() {
}
//Called when the task is paused.
protected override void OnPause() {
}
}
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: b77e2b9ac9aad644480508d5a86f4006

View File

@@ -1,48 +0,0 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace Reset.Movement {
[Category("Reset/Movement")]
[Description("Finalize the move direction to the agent's CharacterController")]
public class FinalizeMovement : ActionTask<CharacterController>{
public BBParameter<Vector3> moveDirection;
public BBParameter<float> currentSpeed;
//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() {
if (currentSpeed == null || !currentSpeed.useBlackboard) {
Debug.LogError("This <b>Finalize Movement</b> does not have it's current value attached to a Blackboard variable. Nothing will happen.", agent.gameObject);
}
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(){
}
//Called once per frame while the action is active.
protected override void OnUpdate(){
Vector3 usableVector3 = new Vector3(moveDirection.value.x * currentSpeed.value, moveDirection.value.y, moveDirection.value.z * currentSpeed.value);
agent.Move(Camera.main.transform.rotation * usableVector3 * Time.deltaTime);
Debug.Log("Finalize Done");
// EndAction(true);
}
//Called when the task is disabled.
protected override void OnStop() {
}
//Called when the task is paused.
protected override void OnPause() {
}
}
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: fea4d34f26d30b24e8cb99acf1766b6f

View File

@@ -1,56 +0,0 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Actions {
[Category("Reset")]
[Description("Hard set the air direction to a certain direction")]
public class SetAirMovement : ActionTask<Transform>{
public BBParameter<Vector3> airMoveDirection;
public BBParameter<Vector3> inputVector3;
public Space fromSpace;
public Space toSpace;
//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() {
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(){
}
//Called once per frame while the action is active.
protected override void OnUpdate() {
if (fromSpace == toSpace) {
airMoveDirection.value = inputVector3.value;
}
// NOTE: I swear to God these absolutely do not work and nobody could convince me otherwise
if (fromSpace == Space.World){
airMoveDirection.value = Camera.main.transform.rotation.Flatten(0, null, 0) * inputVector3.value;
} else {
airMoveDirection.value = Camera.main.transform.rotation.Flatten(0, null, 0) * agent.InverseTransformVector(inputVector3.value);
}
EndAction(true);
}
//Called when the task is disabled.
protected override void OnStop() {
}
//Called when the task is paused.
protected override void OnPause() {
}
}
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: f1db555b92ed94543beab7a2106bc2a3

View File

@@ -1,88 +0,0 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using Reset.Movement;
using UnityEngine;
using UnityEngine.TextCore.Text;
namespace Reset.Player.Movement {
[Category("Reset/Movement")]
[Description("Finalizes the character rotation and commits it to the Transform")]
// TODO: Rename to UpdateRotation
public class UpdateRotation : ActionTask<CharacterController> {
// Rotation
public BBParameter<Vector3> moveDirection;
public BBParameter<PlayerFacingDirection> playerFacingDirection;
public BBParameter<float> rotationSpeed = 5f;
public BBParameter<float> rotationSmoothing;
private Vector3 currentMoveDir;
private PlayerControls controls;
private Quaternion targetRotation;
private float currentRotSpeed;
[ShowIf("playerFacingDirection", 0)]
public Vector3 rotationTargetPosition;
//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() {
controls = agent.GetComponent<PlayerControls>();
return null;
}
//Called once per frame while the action is active.
protected override void OnUpdate() {
// Calculate rotation speed
currentRotSpeed = Mathf.Lerp(currentRotSpeed, rotationSpeed.value, rotationSmoothing.value * Time.deltaTime);
// Set ingitial rotation power
currentRotSpeed = rotationSpeed.value;
// Get input value
Vector3 inputMovement = new Vector3(controls.rawMoveInput.x, 0f, controls.rawMoveInput.y);
switch (playerFacingDirection.value) {
case PlayerFacingDirection.TowardsTarget:
// Set rotation to just the direction of the target
targetRotation = Quaternion.LookRotation((agent.transform.position.DirectionTo(rotationTargetPosition)).Flatten(null, 0));
break;
case PlayerFacingDirection.MatchForward:
if (controls.rawMoveInput.magnitude < 0.01f) { break; }
targetRotation = Quaternion.LookRotation(inputMovement) *
Quaternion.Euler(Camera.main.transform.rotation.eulerAngles.Flatten(0f, null, 0f));
break;
case PlayerFacingDirection.MatchCamera:
// Craft a new rotation that flattens the camera's rotation to the ground
// Needed to keep the character from inheriting the camera's height-rotation
targetRotation = Quaternion.Euler(Camera.main.transform.rotation.eulerAngles.Flatten(0, null, 0));
break;
case PlayerFacingDirection.Static:
targetRotation = agent.transform.rotation;
break;
}
// Set final rotation
agent.transform.rotation = Quaternion.Lerp(agent.transform.rotation, targetRotation, 10f * Time.deltaTime).Flatten(0, null, 0);
Debug.Log("Rotation Done");
EndAction(true);
}
//Called when the task is disabled.
protected override void OnStop() {
}
//Called when the task is paused.
protected override void OnPause() {
}
}
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 7a0fd0ebfb8888b4e8ab4c81fb3aa6c0