maint: deleted old and now unused movement tasks/graphs
This commit is contained in:
@@ -1,33 +0,0 @@
|
|||||||
%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: f945e777233a59f4aba40aeca29093a6, type: 3}
|
|
||||||
m_Name: PlayerLocomotionFSM
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
_serializedGraph: '{"type":"NodeCanvas.StateMachines.FSM","nodes":[{"_actionList":{"executionMode":1,"actions":[]},"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_position":{"x":327.7592,"y":812.7609},"$type":"NodeCanvas.StateMachines.ActionState"},{"_actionList":{"executionMode":1,"actions":[{"moveSpeed":{"_value":12.0},"moveDirection":{"_name":"groundMoveDirection","_targetVariableID":"16ae5ce4-097a-4c21-94a5-2c5d9ce73eb6"},"$type":"NodeCanvas.Tasks.Actions.CalculateGroundedLocomotion"},{"valueA":{"_name":"rotationSpeed","_targetVariableID":"d888730f-97df-4288-bb99-1f6c8a34a7c5"},"valueB":{"_value":10.0},"$type":"NodeCanvas.Tasks.Actions.SetFloat"},{"valueA":{"_name":"facingDirection","_targetVariableID":"c713d622-aafb-43e7-ae0e-ac0b86a85a37"},"valueB":{"_value":1},"$type":"NodeCanvas.Tasks.Actions.SetVariable`1[[PlayerFacingDirection,
|
|
||||||
Core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"}]},"_repeatStateActions":true,"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_position":{"x":389.9924,"y":1029.762},"$type":"NodeCanvas.StateMachines.ActionState"},{"_position":{"x":218.6569,"y":475.1322},"$type":"NodeCanvas.StateMachines.AnyState","$id":"2"},{"_position":{"x":253.0,"y":606.9789},"$type":"NodeCanvas.StateMachines.EmptyState","$id":"3"},{"_onEnterList":{"executionMode":1,"actions":[{"valueA":{"_name":"facingDirection","_targetVariableID":"c713d622-aafb-43e7-ae0e-ac0b86a85a37"},"valueB":{"_value":1},"$type":"NodeCanvas.Tasks.Actions.SetVariable`1[[PlayerFacingDirection,
|
|
||||||
Core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"}]},"_onUpdateList":{"executionMode":1,"actions":[{"moveSpeed":{"_value":12.0},"moveDirection":{"_name":"groundMoveDirection","_targetVariableID":"16ae5ce4-097a-4c21-94a5-2c5d9ce73eb6"},"$type":"NodeCanvas.Tasks.Actions.CalculateGroundedLocomotion"},{"valueA":{"_name":"rotationSpeed","_targetVariableID":"d888730f-97df-4288-bb99-1f6c8a34a7c5"},"valueB":{"_value":10.0},"$type":"NodeCanvas.Tasks.Actions.SetFloat"}]},"_onExitList":{"executionMode":1,"actions":[]},"foldEnter":true,"foldUpdate":true,"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_position":{"x":535.0,"y":768.0},"$type":"NodeCanvas.StateMachines.SuperActionState","$id":"4"},{"_actionList":{"executionMode":1,"actions":[{"moveSpeed":{"_value":30.0},"moveDirection":{"_name":"groundMoveDirection","_targetVariableID":"16ae5ce4-097a-4c21-94a5-2c5d9ce73eb6"},"$type":"NodeCanvas.Tasks.Actions.CalculateGroundedLocomotion"},{"valueA":{"_name":"rotationSpeed","_targetVariableID":"d888730f-97df-4288-bb99-1f6c8a34a7c5"},"valueB":{"_value":1.0},"$type":"NodeCanvas.Tasks.Actions.SetFloat"},{"valueA":{"_name":"facingDirection","_targetVariableID":"c713d622-aafb-43e7-ae0e-ac0b86a85a37"},"valueB":{"_value":2},"$type":"NodeCanvas.Tasks.Actions.SetVariable`1[[PlayerFacingDirection,
|
|
||||||
Core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"}]},"_repeatStateActions":true,"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_position":{"x":917.0839,"y":852.7302},"$type":"NodeCanvas.StateMachines.ActionState","$id":"5"},{"_actionList":{"executionMode":1,"actions":[{"moveSpeed":{"_value":20.0},"moveDirection":{"_name":"groundMoveDirection","_targetVariableID":"16ae5ce4-097a-4c21-94a5-2c5d9ce73eb6"},"$type":"NodeCanvas.Tasks.Actions.CalculateGroundedLocomotion"},{"valueA":{"_name":"rotationSpeed","_targetVariableID":"d888730f-97df-4288-bb99-1f6c8a34a7c5"},"valueB":{"_value":2.0},"$type":"NodeCanvas.Tasks.Actions.SetFloat"}]},"_repeatStateActions":true,"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_position":{"x":1161.288,"y":522.152},"$type":"NodeCanvas.StateMachines.ActionState","$id":"6"},{"_actionList":{"executionMode":1,"actions":[{"moveSpeed":{"_value":5.0},"moveDirection":{"_name":"groundMoveDirection","_targetVariableID":"16ae5ce4-097a-4c21-94a5-2c5d9ce73eb6"},"$type":"NodeCanvas.Tasks.Actions.CalculateGroundedLocomotion"}]},"_repeatStateActions":true,"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_position":{"x":602.0,"y":269.0},"$type":"NodeCanvas.StateMachines.ActionState","$id":"7"},{"_actionList":{"executionMode":1,"actions":[{"moveSpeed":{},"moveDirection":{"_name":"groundMoveDirection","_targetVariableID":"16ae5ce4-097a-4c21-94a5-2c5d9ce73eb6"},"$type":"NodeCanvas.Tasks.Actions.CalculateGroundedLocomotion"}]},"_repeatStateActions":true,"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_position":{"x":402.0,"y":177.0},"$type":"NodeCanvas.StateMachines.ActionState","$id":"8"}],"connections":[{"_condition":{"valueA":{"_name":"isGrounded","_targetVariableID":"321e55c7-f93e-4667-a0dc-559eb61c6898"},"valueB":{},"$type":"NodeCanvas.Tasks.Conditions.CheckBoolean"},"_sourceNode":{"$ref":"2"},"_targetNode":{"$ref":"3"},"_isDisabled":true,"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"eventName":{"_value":"Grapple
|
|
||||||
Aimed"},"$type":"NodeCanvas.Tasks.Conditions.CheckEvent"},"_sourceNode":{"$ref":"2"},"_targetNode":{"$ref":"7"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"eventName":{"_value":"Grapple
|
|
||||||
Confirmed"},"$type":"NodeCanvas.Tasks.Conditions.CheckEvent"},"_sourceNode":{"$ref":"2"},"_targetNode":{"$ref":"8"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"valueA":{"_name":"isGrounded","_targetVariableID":"321e55c7-f93e-4667-a0dc-559eb61c6898"},"valueB":{"_value":true},"$type":"NodeCanvas.Tasks.Conditions.CheckBoolean"},"_sourceNode":{"$ref":"3"},"_targetNode":{"$ref":"4"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"actionName":{"_value":"Sprint"},"actionPhase":{"_value":3},"$type":"NodeCanvas.Tasks.Conditions.CheckInput"},"_sourceNode":{"$ref":"4"},"_targetNode":{"$ref":"5"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"timeout":{"_value":0.1},"$type":"NodeCanvas.Tasks.Conditions.Timeout"},"_sourceNode":{"$ref":"5"},"_targetNode":{"$ref":"6"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"checkAgainst":2,"checkAgainstValue":{"_value":{"z":1.0}},"desiredValue":{"_value":1.0},"tolerance":{"_value":0.32},"considerCameraRotation":{},"negate":{},"$type":"NodeCanvas.Tasks.Conditions.GetMovementInputDotProduct"},"_sourceNode":{"$ref":"6"},"_targetNode":{"$ref":"4"},"$type":"NodeCanvas.StateMachines.FSMConnection"}],"canvasGroups":[],"localBlackboard":{"_variables":{"isGrounded":{"_propertyPath":"UnityEngine.CharacterController.isGrounded","_name":"isGrounded","_id":"321e55c7-f93e-4667-a0dc-559eb61c6898","$type":"NodeCanvas.Framework.Variable`1[[System.Boolean,
|
|
||||||
mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"},"groundMoveDirection":{"_name":"groundMoveDirection","_id":"16ae5ce4-097a-4c21-94a5-2c5d9ce73eb6","_isPublic":true,"$type":"NodeCanvas.Framework.Variable`1[[UnityEngine.Vector3,
|
|
||||||
UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"},"rotationSpeed":{"_name":"rotationSpeed","_id":"d888730f-97df-4288-bb99-1f6c8a34a7c5","_isPublic":true,"$type":"NodeCanvas.Framework.Variable`1[[System.Single,
|
|
||||||
mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"},"facingDirection":{"_name":"facingDirection","_id":"c713d622-aafb-43e7-ae0e-ac0b86a85a37","_isPublic":true,"$type":"NodeCanvas.Framework.Variable`1[[PlayerFacingDirection,
|
|
||||||
Core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"}}}}'
|
|
||||||
_objectReferences: []
|
|
||||||
_graphSource:
|
|
||||||
_version: 3.31
|
|
||||||
_category:
|
|
||||||
_comments:
|
|
||||||
_translation: {x: 467, y: -132}
|
|
||||||
_zoomFactor: 0.9793777
|
|
||||||
_haltSerialization: 0
|
|
||||||
_externalSerializationFile: {fileID: 0}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: b307c218c1a404548afe65e66737fa80
|
|
||||||
NativeFormatImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
mainObjectFileID: 11400000
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -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() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 86e5b037e41d5bb4b8805890ee72ad29
|
|
||||||
@@ -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() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 38d61a72cc7757448b3db6c04395cf91
|
|
||||||
@@ -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() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 808dc54c4ce75e846890125a4f87e516
|
|
||||||
@@ -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() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: b77e2b9ac9aad644480508d5a86f4006
|
|
||||||
@@ -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() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: fea4d34f26d30b24e8cb99acf1766b6f
|
|
||||||
@@ -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() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: f1db555b92ed94543beab7a2106bc2a3
|
|
||||||
@@ -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() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 7a0fd0ebfb8888b4e8ab4c81fb3aa6c0
|
|
||||||
Reference in New Issue
Block a user