fixed: various movement and air control fixes and tweaks, various clean up

This commit is contained in:
Chris
2025-07-29 17:38:52 -04:00
parent 39313c96d0
commit ae1908013d
9 changed files with 52 additions and 37 deletions

View File

@@ -19,8 +19,6 @@ namespace NodeCanvas.Tasks.Actions {
[SliderField(0, 1)]
public BBParameter<float> standStillJumpStrength;
[Tooltip("Determines how much current movement vectors into jump direction")]
[SliderField(0, 1)]
public BBParameter<float> currentVelocityInheritence;

View File

@@ -3,16 +3,13 @@ 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;
public BBParameter<Vector3> groundMoveDirection; // Unused on 7/29/25, delete if still unusued later
public BBParameter<PlayerFacingDirection> playerFacingDirection;
private float airControlPower = 1f;
//Use for initialization. This is called only once in the lifetime of the task.
@@ -25,7 +22,7 @@ namespace NodeCanvas.Tasks.Actions {
//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.
@@ -34,7 +31,7 @@ namespace NodeCanvas.Tasks.Actions {
airMoveDirection.value = Vector3.Lerp(airMoveDirection.value, Vector3.zero, .7f * Time.deltaTime);
// Decay Air Control power
airControlPower = Mathf.Lerp(airControlPower, 0f, 3f * Time.deltaTime);
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);
@@ -47,7 +44,7 @@ namespace NodeCanvas.Tasks.Actions {
//Called when the task is disabled.
protected override void OnStop() {
groundMoveDirection.value = agent.GetComponent<CharacterController>().velocity;
// groundMoveDirection.value = agent.GetComponent<CharacterController>().velocity;
EndAction(true);
}

View File

@@ -66,7 +66,7 @@ namespace NodeCanvas.Tasks.Actions {
break;
case TransformProperty.Rotation:
// agent.transform = Quaternion.Euler(relativeValue.value + targetValue.value);
agent.transform.rotation = Quaternion.LookRotation(relativeValue.value) * Quaternion.Euler(targetValue.value);
break;
case TransformProperty.Scale:
break;
@@ -99,7 +99,7 @@ namespace NodeCanvas.Tasks.Actions {
break;
case TransformProperty.Rotation:
agent.transform.rotation = Quaternion.Euler(relativeValue.value + targetValue.value);
agent.transform.rotation = Quaternion.Euler(relativeValue.value) * Quaternion.Euler(targetValue.value);
break;
case TransformProperty.Scale:
break;

View File

@@ -44,6 +44,7 @@ namespace NodeCanvas.Tasks.Actions {
private float currentRotSpeed;
private float lastLookMagnitude;
private Quaternion targetRotation;
private Vector3 currentMoveDir;
// References
private PlayerControls controls;
@@ -56,7 +57,7 @@ namespace NodeCanvas.Tasks.Actions {
// Append the late update method to actually happen on late update
MonoManager.current.onLateUpdate += LateUpdate;
// What
// Set ingitial rotation power
currentRotSpeed = rotationSpeed.value;
// Reference to controls
@@ -68,8 +69,8 @@ namespace NodeCanvas.Tasks.Actions {
//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() {
protected override void OnExecute(){
currentMoveDir = groundMoveDirection.value;
}
//Called once per frame while the action is active.
@@ -92,8 +93,12 @@ namespace NodeCanvas.Tasks.Actions {
if (controls.rawMoveInput.magnitude == 0) { break; }
// Set desired rotation to input direction, with respect to camera rotation
targetRotation = Quaternion.LookRotation(new Vector3(controls.rawMoveInput.x, 0, controls.rawMoveInput.y)) *
Quaternion.Euler(Camera.main.transform.rotation.eulerAngles.Flatten(0f, null, 0f));
if (agent.isGrounded){
targetRotation = Quaternion.LookRotation(currentMoveDir) *
Quaternion.Euler(Camera.main.transform.rotation.eulerAngles.Flatten(0f, null, 0f));
} else {
targetRotation = Quaternion.LookRotation(airMoveDirection.value);
}
break;
case PlayerFacingDirection.MatchCamera:
// Craft a new rotation that flattens the camera's rotation to the ground
@@ -108,10 +113,13 @@ namespace NodeCanvas.Tasks.Actions {
// Construct move direction
Vector3 finalMoveDir = Vector3.zero;
Vector3 gravityMoveDirection;
// Change how input is managed based on facing state
currentMoveDir = Vector3.Slerp(currentMoveDir, groundMoveDirection.value, currentRotSpeed * Time.deltaTime);
// Add input movement
if (agent.isGrounded){
finalMoveDir += groundMoveDirection.value + Vector3.down * .03f;
finalMoveDir += currentMoveDir + Vector3.down * .03f;
gravityMoveDirection = new(0f, jumpPower.value + (Physics.gravity.y *.3f), 0f);
} else {
finalMoveDir += airMoveDirection.value;
@@ -131,7 +139,7 @@ namespace NodeCanvas.Tasks.Actions {
}
// Set final rotation
agent.transform.rotation = Quaternion.Lerp(agent.transform.rotation, targetRotation, 10f * Time.deltaTime);
agent.transform.rotation = Quaternion.Lerp(agent.transform.rotation, targetRotation, 10f * Time.deltaTime).Flatten(0, null, 0);
// ???? Moved this above but don't remember if this needs to be here still
if (agent.isGrounded) {