first commit

This commit is contained in:
Chris
2025-03-12 14:22:16 -04:00
commit 0ad0c01249
1999 changed files with 189708 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f09426c2a21818a429cc18d1d635ff37
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,47 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions {
[Category("Core/Input")]
[Description("Returns a float from two Vector3s")]
public class GetMovementInputDotProduct : ConditionTask<PlayerControls>{
[SliderField(0f,1f)]
public BBParameter<Vector3> desiredVector3;
public BBParameter<float> tolerance;
public BBParameter<bool> negate;
//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 bool OnCheck(){
Vector3 rawInputVector3 = new(agent.rawMoveInput.x, 0f, agent.rawMoveInput.y);
float dotProduct = Vector3.Dot(desiredVector3.value, rawInputVector3);
//Debug.Log(dotProduct);
if (dotProduct < tolerance.value) {
return true;
}
return false;
}
//Called when the task is disabled.
protected override void OnEnable() {
}
//Called when the task is paused.
protected override void OnDisable() {
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 18fad1a66e9673c4f895560eee9e050d

View File

@@ -0,0 +1,54 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Actions {
[Category("Core/Movement")]
public class CalculateAirMovement : ActionTask<Transform>{
public BBParameter<Vector3> airMoveDirection;
public BBParameter<Vector3> groundMoveDirection;
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, 3f * 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 * 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

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

View File

@@ -0,0 +1,49 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
using UnityEngine.InputSystem;
namespace NodeCanvas.Tasks.Conditions {
[Category("Core")]
[Description("Check if input condition was matched this frame")]
public class CheckInput : ConditionTask<Transform>{
public BBParameter<string> actionName;
public BBParameter<string> actionValue;
protected override string info {
get { return "Player Input"; }
}
private InputAction action;
//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;
}
//Called whenever the condition gets enabled.
protected override void OnEnable(){
action = agent.GetComponent<PlayerInput>().actions.FindAction(actionName.value);
}
//Called whenever the condition gets disabled.
protected override void OnDisable() {
}
//Called once per frame while the condition is active.
//Return whether the condition is success or failure.
protected override bool OnCheck() {
// if (action.type == InputActionType.Button){
if (action.WasPressedThisFrame()) { return true; }
// } else if (action.type == InputActionType.Value) {
//
// }
return false;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 89d86f6c4779bf2459076f04cdce4c0e

View File

@@ -0,0 +1,154 @@
using System;
using System.Linq;
using NodeCanvas.Framework;
using ParadoxNotion;
using ParadoxNotion.Design;
using UnityEngine;
using UnityEngine.InputSystem;
namespace NodeCanvas.Tasks.Actions {
[Category("Reset/Actions")]
public class Jump : ActionTask<CharacterController> {
public BBParameter<float> jumpStrength;
public BBParameter<Vector3> airMoveDirection;
[Range(0f, 1f)]
public BBParameter<float> standStillJumpStrength;
public BBParameter<float> jumpPower;
[Tooltip("Determines how much current movement vectors into jump direction")]
public BBParameter<float> currentVelocityInheritence;
public BBParameter<Vector3> directionalForce;
public BBParameter<float> directionalForceStrength;
protected override string info {
get { return "Start Jump" ; }
}
//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;
{ /* // The following creates an air movement direction initially constructed from the agent's velocity, but also from subsequent jump inputs
// // Create a vector 3 to hold velocity without jump power or gravity
// Vector3 velocityWithoutY = new(agent.velocity.x, 0f, agent.velocity.z);
// Vector3 jumpLeapVelocity = new (velocityWithoutY.x, velocityWithoutY.y, velocityWithoutY.z);
//
// float inputVelocityMagnitude = velocityWithoutY.magnitude;
// float usableVelocity = 0f;
//
// // Ungrounded players can input a jump command to take their relative velcity as input for the new direction
// if(!agent.isGrounded){
// // Get raw input direction
// Vector3 playerInputVector3 = new(agent.GetComponent<PlayerControls>().rawMoveInput.x, 0f, agent.GetComponent<PlayerControls>().rawMoveInput.y);
//
// // Compare current velocity magnitude against jump strength. This is so air movement with no inherit velocity can be overidden by the new jump.
// usableVelocity = Mathf.Abs(velocityWithoutY.magnitude - jumpStrength.value);
// usableVelocity = Mathf.Max(usableVelocity, 0f);
// usableVelocity /= jumpStrength.value;
// // Debug.Log(usableVelocity);
//
// // Lerp between leaping and adding the full jump strenght, or adding a portion of it
// Vector3 fullNewValueVelocity = agent.transform.rotation * playerInputVector3.normalized * jumpStrength.value;
// Vector3 fullOriginalValueVelocity = velocityWithoutY;
//
// jumpLeapVelocity = Vector3.Lerp(fullNewValueVelocity, fullOriginalValueVelocity, 1f - usableVelocity);
// } else {
//
// }
//
// // Add directional force, for things such as wall bounces
// Vector3 directionalForceDirection = new Vector3(directionalForce.value.x, 0f, directionalForce.value.y);
// jumpLeapVelocity += (agent.transform.rotation * directionalForce.value) * directionalForceStrength.value;
//
//
// jumpLeapVelocity *= currentVelocityInheritence.value;
// if (agent.isGrounded){
// jumpLeapVelocity = Vector3.ClampMagnitude(jumpLeapVelocity, velocityWithoutY.magnitude);
// } else {
// jumpLeapVelocity = Vector3.ClampMagnitude(jumpLeapVelocity, Mathf.Lerp(velocityWithoutY.magnitude, jumpStrength.value, usableVelocity));
// }
//
// // Debug.Log(jumpLeapVelocity);
//
// airMoveDirection.value = jumpLeapVelocity; */ }
// 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(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 outputVelocity = Mathf.Lerp(jumpStrength.value, currentVelocityVector3.magnitude, Math.Clamp(magnitudeZeroDifference, 0f, 1f));
outputVelocity = Mathf.Min(outputVelocity, Mathf.Lerp(standStillJumpStrength.value * jumpStrength.value, jumpStrength.value * .4f, magnitudeZeroDifference));
// 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(.3f, 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(currentVelocityVector3.normalized, currentInputVector3.normalized, remappedAirDirectionDot);
// If there is a direction force, 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;
// Set air move direciton
airMoveDirection.value += outputDirection * outputVelocity;
}
// Transform and apply rotatio
agent.transform.rotation = Quaternion.LookRotation(airMoveDirection.value);
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

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

View File

@@ -0,0 +1,83 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Actions {
[Category("Core/Movement")]
[Description("Unit flat ground movement")]
public class ProcessFlatLocomotion : ActionTask<CharacterController>{
public BBParameter<float> baseMoveSpeed;
public BBParameter<float> sprintAdditionalSpeed;
public BBParameter<Vector3> moveDirection;
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 += baseMoveSpeed.value;
// Add sprinting speed
// TODO: Take this sprinting section out and move it into it's own task. Sprinting should be a state in the ground locomotion graph.
if (sprinting) {
sprintPower = Mathf.Lerp(sprintPower, 1, sprintAdditionalSpeed.value * Time.deltaTime);
outputSpeed += (sprintAdditionalSpeed.value * sprintPower);
} else {
outputSpeed += (sprintAdditionalSpeed.value * sprintPower);
sprintPower = Mathf.Lerp(sprintPower, 0, sprintAdditionalSpeed.value * Time.deltaTime);
}
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

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

View File

@@ -0,0 +1,67 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using ParadoxNotion.Services;
using UnityEngine;
namespace NodeCanvas.Tasks.Actions {
[Category("Core/Movement")]
public class ProcessGravity : ActionTask<CharacterController>{
public BBParameter<float> gravityScale = 1f;
public BBParameter<float> gravityAcceleration = 1f;
public BBParameter<float> gravityMax = 8f;
private Vector3 currentVelocity;
private bool freezeVelocity;
private float gravityPower;
//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(){
MonoManager.current.onLateUpdate += LateUpdate;
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 (!freezeVelocity && agent.velocity != Vector3.zero){
currentVelocity = new Vector3(agent.velocity.x, 0f, agent.velocity.y);
}
}
void LateUpdate(){
if (agent.isGrounded) {
gravityPower = 0f;
currentVelocity = Vector3.zero;
freezeVelocity = true;
agent.Move(Physics.gravity * .1f * Time.deltaTime);
} else {
if (currentVelocity == Vector3.zero && agent.velocity.y < 0f) {
freezeVelocity = false;
}
Debug.Log(currentVelocity);
agent.Move((Physics.gravity * gravityPower * Time.deltaTime));
}
}
//Called when the task is disabled.
protected override void OnStop() {
EndAction(true);
}
//Called when the task is paused.
protected override void OnPause() {
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5c6c0f191ca8a3d4cb402d351413dff3

View File

@@ -0,0 +1,129 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using ParadoxNotion.Services;
using Unity.Mathematics;
using UnityEngine;
namespace NodeCanvas.Tasks.Actions {
[Category("Core/Movement")]
[Description("Finalizes movement and sends the final move commands to the controller")]
public class ProcessMovement : ActionTask<CharacterController>{
public BBParameter<Vector3> groundMoveDirection;
public BBParameter<Vector3> airMoveDirection;
[Space(5)]
public BBParameter<float> gravityAcceleration = 1f;
public BBParameter<float> gravityMax = 8f;
public BBParameter<float> jumpPower;
public BBParameter<float> jumpPowerDecay;
public BBParameter<float> rotationSpeed = 5f;
public BBParameter<float> rotationSmoothing;
private float currentRotSpeed;
private Vector3 rotationNoY;
public BBParameter<float> gravityPower;
//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() {
MonoManager.current.onLateUpdate += LateUpdate;
currentRotSpeed = rotationSpeed.value;
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 input values
Vector2 rawLookInputVector3 = agent.GetComponent<PlayerControls>().rawLookInput;
Vector2 rawMoveInputVector3 = agent.GetComponent<PlayerControls>().rawMoveInput;
gravityPower.value += gravityAcceleration.value * Time.deltaTime;
gravityPower.value = Mathf.Min(gravityPower.value, gravityMax.value);
// Calculate rotation speed
currentRotSpeed = Mathf.Lerp(currentRotSpeed, rotationSpeed.value, rotationSmoothing.value * Time.deltaTime);
// Process input rotation
agent.transform.Rotate(new Vector3(0, agent.GetComponent<PlayerControls>().rawLookInput.x * rotationSpeed.value * 360f * Time.deltaTime)); // *360 to account for a full circle taking a long ass time
// Process movement rotation
if (agent.isGrounded){
// Quaternion cameraRotNoY = Quaternion.Euler(0f, Camera.main.transform.rotation.eulerAngles.y , 0f);
// agent.transform.rotation = Quaternion.Lerp(agent.transform.rotation, Quaternion.LookRotation(agent.transform.position + groundMoveDirection.value), 10f * Time.deltaTime);
} else {
// rotationNoY = airMoveDirection.value;
// rotationNoY.x = 0f;
// rotationNoY.z = 0f;
// agent.transform.rotation = Quaternion.Lerp(agent.transform.rotation, Quaternion.Euler(rotationNoY), 5f * Time.deltaTime);
}
// Construct move direction
Vector3 finalMoveDir = Vector3.zero;
Vector3 gravityMoveDirection;
// Create movement direction for ground movement based on move direction, facing direction, and input
// Start by lerping facing direction towards move direction based on input power
rotationNoY = airMoveDirection.value;
rotationNoY.x = 0f;
rotationNoY.z = 0f;
// agent.transform.rotation = Quaternion.RotateTowards(agent.transform.rotation, Quaternion.Euler(rotationNoY), )
// Vector3 groundMoveDirModified = Vector3.Lerp();
// Add input movement
if (agent.isGrounded){
Quaternion cameraRotNoY = Quaternion.Euler(0f, Camera.main.transform.rotation.eulerAngles.y , 0f);
finalMoveDir += groundMoveDirection.value + Vector3.down * .03f;
gravityMoveDirection = new(0f, jumpPower.value + (Physics.gravity.y *.08f), 0f);
} else {
finalMoveDir += airMoveDirection.value;
gravityMoveDirection = new(0f, jumpPower.value + Physics.gravity.y * gravityPower.value, 0f);
}
// Do final movement
if (agent.isGrounded) {
agent.Move((Camera.main.transform.rotation * finalMoveDir + gravityMoveDirection) * Time.deltaTime);
} else {
agent.Move((finalMoveDir + gravityMoveDirection) * Time.deltaTime);
}
// Reset gravity power when grounded
if (agent.isGrounded) {
gravityPower.value = 0f;
}
if (agent.isGrounded) {
jumpPower.value = 0f;
}
}
// Gravity is processed in LateUpdate (added to MonoManager's onLateUpdate in OnInit())
public void LateUpdate(){
// Decay jump power
jumpPower.value = Mathf.Lerp(jumpPower.value, 0f, jumpPowerDecay.value * Time.deltaTime);
}
//Called when the task is disabled.
protected override void OnStop() {
EndAction(true);
}
//Called when the task is paused.
protected override void OnPause() {
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 69daf571854fd8046a60a7baab64cc18

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 99f42c94513cd47418459d3454124497
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,15 @@
using UnityEngine;
using System;
using Unity.Netcode.Transports.UTP;
public class SessionManager : MonoBehaviour{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start(){
}
// Update is called once per frame
void Update(){
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 31709e0224b48e24b8e5311541392a97