mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-16 15:26:33 -05:00
Finished the Movement and Aerial groups
Working on the Dash, Nitro, and offense groups now
This commit is contained in:
@@ -5245,9 +5245,9 @@ MonoBehaviour:
|
||||
playerGrav: 200
|
||||
gravVel: 0
|
||||
hasBlink: 0
|
||||
hasGlider: 0
|
||||
hasGrapple: 0
|
||||
hasWallrun: 0
|
||||
hasGlider: 1
|
||||
hasGrapple: 1
|
||||
hasWallrun: 1
|
||||
hasNitro: 0
|
||||
hasDash: 0
|
||||
playerPoints: 15
|
||||
@@ -5293,6 +5293,7 @@ MonoBehaviour:
|
||||
rB: {fileID: 0}
|
||||
capCol: {fileID: 0}
|
||||
pStats: {fileID: 0}
|
||||
aSM: {fileID: 0}
|
||||
idleLimit: 0.3
|
||||
walkLimit: 10
|
||||
jogLimit: 20
|
||||
@@ -5330,6 +5331,21 @@ MonoBehaviour:
|
||||
fallMultiplier: 1.6
|
||||
isGrounded: 0
|
||||
groundCheckDistance: 0.05
|
||||
isWallRunning: 0
|
||||
maxGrabDistance: 30
|
||||
hookPoint: {fileID: 0}
|
||||
hookPoints: []
|
||||
hookPointIndex: 0
|
||||
distance: 0
|
||||
maxGrappleDistance: 20
|
||||
maxSwingSpeed: 50
|
||||
minSwingSpeed: 20
|
||||
swingAcc: 3
|
||||
maxSwingMom: 60
|
||||
release: 0
|
||||
tempRelease: {x: 0, y: 0, z: 0}
|
||||
lerpRelease: {x: 0, y: 0, z: 0}
|
||||
forceDirection: {x: 0, y: 0, z: 0}
|
||||
--- !u!4 &4090990814600649861
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -4,10 +4,14 @@ using UnityEngine;
|
||||
|
||||
public class AerialFallingState : AerialBaseState
|
||||
{
|
||||
public override void EnterState(AerialStateManager aSM){
|
||||
public override void EnterState(AerialStateManager aSM, AerialBaseState previousState){
|
||||
Debug.Log("Falling State");
|
||||
}
|
||||
|
||||
public override void ExitState(AerialStateManager aSM, AerialBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(AerialStateManager aSM){
|
||||
if(aSM.pStats.GravVel > 0){
|
||||
aSM.SwitchState(aSM.JumpingState);
|
||||
@@ -19,13 +23,21 @@ public class AerialFallingState : AerialBaseState
|
||||
if(aSM.isGrounded){
|
||||
aSM.SwitchState(aSM.GroundedState);
|
||||
}
|
||||
|
||||
if(aSM.isWallRunning && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
|
||||
aSM.SwitchState(aSM.WallRunState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(AerialStateManager aSM){
|
||||
aSM.GravityCalculation(aSM.pStats.PlayerGrav);
|
||||
}
|
||||
|
||||
public override void OnCollisionEnter(AerialStateManager aSM){
|
||||
if(aSM.pStats.HasGrapple){
|
||||
aSM.GrappleReleaseForce();
|
||||
}
|
||||
|
||||
if(aSM.CheckGrapple() && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
|
||||
aSM.SwitchState(aSM.GrappleAirState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,30 +6,40 @@ public class AerialGlidingState : AerialBaseState
|
||||
{
|
||||
float tempTraction;
|
||||
|
||||
public override void EnterState(AerialStateManager aSM){
|
||||
public override void EnterState(AerialStateManager aSM, AerialBaseState previousState){
|
||||
Debug.Log("Gliding State");
|
||||
|
||||
tempTraction = aSM.pStats.Traction;
|
||||
aSM.pStats.Traction = 1.0f;
|
||||
}
|
||||
|
||||
public override void ExitState(AerialStateManager aSM, AerialBaseState nextState){
|
||||
aSM.pStats.Traction = tempTraction;
|
||||
}
|
||||
|
||||
public override void UpdateState(AerialStateManager aSM){
|
||||
if(!Input.GetButton("Jump")){
|
||||
aSM.pStats.Traction = tempTraction;
|
||||
aSM.SwitchState(aSM.FallingState);
|
||||
}
|
||||
|
||||
if(aSM.isGrounded){
|
||||
aSM.pStats.Traction = tempTraction;
|
||||
aSM.SwitchState(aSM.GroundedState);
|
||||
}
|
||||
|
||||
if(aSM.isWallRunning && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
|
||||
aSM.SwitchState(aSM.WallRunState);
|
||||
}
|
||||
|
||||
if(aSM.CheckGrapple() && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
|
||||
aSM.SwitchState(aSM.GrappleAirState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(AerialStateManager aSM){
|
||||
aSM.GravityCalculation(9);
|
||||
}
|
||||
|
||||
public override void OnCollisionEnter(AerialStateManager aSM){
|
||||
|
||||
if(aSM.pStats.HasGrapple){
|
||||
aSM.GrappleReleaseForce();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,14 @@ using UnityEngine;
|
||||
|
||||
public class AerialGroundedState : AerialBaseState
|
||||
{
|
||||
public override void EnterState(AerialStateManager aSM){
|
||||
public override void EnterState(AerialStateManager aSM, AerialBaseState previousState){
|
||||
Debug.Log("Grounded State");
|
||||
|
||||
aSM.release = false;
|
||||
}
|
||||
|
||||
public override void ExitState(AerialStateManager aSM, AerialBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(AerialStateManager aSM){
|
||||
@@ -15,13 +21,13 @@ public class AerialGroundedState : AerialBaseState
|
||||
else if(aSM.pStats.GravVel > 0){
|
||||
aSM.SwitchState(aSM.JumpingState);
|
||||
}
|
||||
|
||||
if(aSM.CheckGrapple() && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
|
||||
aSM.SwitchState(aSM.GrappleGroundedState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(AerialStateManager aSM){
|
||||
aSM.GravityCalculation(aSM.pStats.PlayerGrav);
|
||||
}
|
||||
|
||||
public override void OnCollisionEnter(AerialStateManager aSM){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,14 @@ using UnityEngine;
|
||||
public class AerialJumpingState : AerialBaseState
|
||||
{
|
||||
|
||||
public override void EnterState(AerialStateManager aSM){
|
||||
public override void EnterState(AerialStateManager aSM, AerialBaseState previousState){
|
||||
Debug.Log("Jumping State");
|
||||
}
|
||||
|
||||
public override void ExitState(AerialStateManager aSM, AerialBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(AerialStateManager aSM){
|
||||
|
||||
if(aSM.pStats.GravVel < 0){
|
||||
@@ -18,13 +22,21 @@ public class AerialJumpingState : AerialBaseState
|
||||
if(aSM.isGrounded){
|
||||
aSM.SwitchState(aSM.GroundedState);
|
||||
}
|
||||
|
||||
if(aSM.isWallRunning && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
|
||||
aSM.SwitchState(aSM.WallRunState);
|
||||
}
|
||||
|
||||
if(aSM.CheckGrapple() && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
|
||||
aSM.SwitchState(aSM.GrappleAirState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(AerialStateManager aSM){
|
||||
aSM.GravityCalculation(aSM.pStats.PlayerGrav);
|
||||
}
|
||||
|
||||
public override void OnCollisionEnter(AerialStateManager aSM){
|
||||
|
||||
if(aSM.pStats.HasGrapple){
|
||||
aSM.GrappleReleaseForce();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,9 @@ using UnityEngine;
|
||||
|
||||
public abstract class AerialBaseState
|
||||
{
|
||||
public abstract void EnterState(AerialStateManager aSM);
|
||||
public abstract void EnterState(AerialStateManager aSM, AerialBaseState previousState);
|
||||
public abstract void ExitState(AerialStateManager aSM, AerialBaseState nextState);
|
||||
public abstract void UpdateState(AerialStateManager aSM);
|
||||
public abstract void FixedUpdateState(AerialStateManager aSM);
|
||||
public abstract void OnCollisionEnter(AerialStateManager aSM);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
using MLAPI;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
public class AerialStateManager : MonoBehaviour
|
||||
{
|
||||
@@ -13,18 +16,26 @@ public class AerialStateManager : MonoBehaviour
|
||||
public AerialGlidingState GlidingState = new AerialGlidingState();
|
||||
public AerialGroundedState GroundedState = new AerialGroundedState();
|
||||
public AerialJumpingState JumpingState = new AerialJumpingState();
|
||||
|
||||
//Wallrunning States
|
||||
public AerialWallRunState WallRunState = new AerialWallRunState();
|
||||
public AerialWallIdleState WallIdleState = new AerialWallIdleState();
|
||||
|
||||
//Grappling States
|
||||
public AerialGrappleGroundedState GrappleGroundedState = new AerialGrappleGroundedState();
|
||||
public AerialGrappleAirState GrappleAirState = new AerialGrappleAirState();
|
||||
////
|
||||
|
||||
////Objects Sections
|
||||
private GameObject parentObj; // Parent object
|
||||
GameObject parentObj; // Parent object
|
||||
public Camera cam; // Camera object
|
||||
////
|
||||
|
||||
////Components Section
|
||||
public CharacterController moveController; // Character Controller
|
||||
private Rigidbody rB; // Players Rigidbody
|
||||
private CapsuleCollider capCol; // Players Capsule Collider
|
||||
private Animator animator; // Animation Controller
|
||||
Rigidbody rB; // Players Rigidbody
|
||||
CapsuleCollider capCol; // Players Capsule Collider
|
||||
Animator animator; // Animation Controller
|
||||
////
|
||||
|
||||
////Scripts Section
|
||||
@@ -36,22 +47,61 @@ public class AerialStateManager : MonoBehaviour
|
||||
//Jump Variables
|
||||
public int curJumpNum; // current Jumps Used
|
||||
public bool jumpHeld; // Jump is Held
|
||||
private bool jumpPressed; // Jamp was pressed
|
||||
bool jumpPressed; // Jamp was pressed
|
||||
public float coyJumpTimer = 0.1f; // Default Coyote Jump time
|
||||
public float curCoyJumpTimer = 0.1f; // current Coyote Jump time
|
||||
public float lowJumpMultiplier; // Short jump multiplier
|
||||
public float fallMultiplier; // High Jump Multiplier
|
||||
|
||||
//Gravity Variables//
|
||||
private float maxG = -100; // max downwards velocity
|
||||
float maxG = -100; // max downwards velocity
|
||||
|
||||
//Ground Check
|
||||
public bool isGrounded; // is player grounded
|
||||
public float groundCheckDistance = 0.05f; // offset distance to check ground
|
||||
private const float jumpGroundingPreventionTime = 0.2f; // delay so player doesn't get snapped to ground while jumping
|
||||
private const float groundCheckDistanceInAir = 0.07f; // How close we have to get to ground to start checking for grounded again
|
||||
private Ray groundRay; // ground ray
|
||||
private RaycastHit groundHit; // ground raycast
|
||||
const float jumpGroundingPreventionTime = 0.2f; // delay so player doesn't get snapped to ground while jumping
|
||||
const float groundCheckDistanceInAir = 0.07f; // How close we have to get to ground to start checking for grounded again
|
||||
Ray groundRay; // ground ray
|
||||
RaycastHit groundHit; // ground raycast
|
||||
|
||||
//Wallrun
|
||||
float wallMaxDistance = 3f;
|
||||
float wallSpeedMultiplier = 1.5f;
|
||||
float minimumHeight = .1f;
|
||||
[Range(0.0f, 1.0f)]
|
||||
float normalizedAngleThreshold = 0.1f;
|
||||
float jumpDuration = .02f;
|
||||
float wallBouncing = 3;
|
||||
Vector3[] directions;
|
||||
RaycastHit[] hits;
|
||||
public bool isWallRunning = false;
|
||||
Vector3 lastWallPosition;
|
||||
Vector3 lastWallNormal;
|
||||
float elapsedTimeSinceJump = 0;
|
||||
float elapsedTimeSinceWallAttach = 0;
|
||||
float elapsedTimeSinceWallDetatch = 0;
|
||||
bool jumping;
|
||||
|
||||
//Impact Variables
|
||||
float mass = 5.0F; // mass variable for Impact
|
||||
Vector3 impact = Vector3.zero; // Impact Vector
|
||||
|
||||
//Grapple Variables
|
||||
public float maxGrabDistance = 30;// Max Distance can cast grapple
|
||||
public GameObject hookPoint; // Actual Hook points
|
||||
public GameObject[] hookPoints; // Hook point list
|
||||
public int hookPointIndex; // Hook point Index
|
||||
public float distance; // distance of hookpoints
|
||||
public float maxGrappleDistance = 20; // Max Rope Length
|
||||
public float maxSwingSpeed = 50;
|
||||
public float minSwingSpeed = 20;
|
||||
public float swingAcc = 3f;
|
||||
public float maxSwingMom = 60;
|
||||
public bool release = false;
|
||||
public Vector3 tempRelease;
|
||||
public Vector3 lerpRelease;
|
||||
public Vector3 forceDirection;
|
||||
public bool eHeld;
|
||||
////
|
||||
|
||||
void Awake(){
|
||||
@@ -67,7 +117,7 @@ public class AerialStateManager : MonoBehaviour
|
||||
|
||||
////Initialize Scripts
|
||||
pStats = GetComponent<PlayerStats>(); // set PlayerStats
|
||||
mSM = GetComponent<MoveStateManager>();
|
||||
mSM = GetComponent<MoveStateManager>(); // set move state manager
|
||||
////
|
||||
}
|
||||
|
||||
@@ -75,7 +125,21 @@ public class AerialStateManager : MonoBehaviour
|
||||
//players starting state
|
||||
currentState = GroundedState;
|
||||
previousState = GroundedState;
|
||||
currentState.EnterState(this);
|
||||
currentState.EnterState(this, previousState);
|
||||
|
||||
////Initialize Variables
|
||||
//Wallrun Variables
|
||||
directions = new Vector3[]{
|
||||
Vector3.right,
|
||||
Vector3.right + Vector3.forward,
|
||||
Vector3.forward,
|
||||
Vector3.left + Vector3.forward,
|
||||
Vector3.left
|
||||
};
|
||||
|
||||
//Grapple Variables
|
||||
hookPoints = GameObject.FindGameObjectsWithTag("HookPoint");
|
||||
////
|
||||
}
|
||||
|
||||
void Update(){
|
||||
@@ -85,10 +149,19 @@ public class AerialStateManager : MonoBehaviour
|
||||
|
||||
void FixedUpdate(){
|
||||
|
||||
//calls any logic in the fixed update state from current state
|
||||
currentState.FixedUpdateState(this);
|
||||
if(moveController.enabled){
|
||||
Jump();
|
||||
GroundCheck();
|
||||
DownwardMovement();
|
||||
|
||||
if(pStats.HasWallrun){
|
||||
WallRunRoutine();
|
||||
}
|
||||
|
||||
//Dissipates Impact
|
||||
DissipateImpact();
|
||||
}
|
||||
else{
|
||||
//Gravity without moveController
|
||||
@@ -97,20 +170,23 @@ public class AerialStateManager : MonoBehaviour
|
||||
}
|
||||
|
||||
|
||||
//calls any logic in the fixed update state from current state
|
||||
currentState.FixedUpdateState(this);
|
||||
|
||||
}
|
||||
|
||||
public void SwitchState(AerialBaseState state){
|
||||
|
||||
currentState.ExitState(this, state);
|
||||
|
||||
//Sets the previous State
|
||||
previousState = currentState;
|
||||
|
||||
//updates current state and calls logic for entering
|
||||
currentState = state;
|
||||
currentState.EnterState(this);
|
||||
currentState.EnterState(this, previousState);
|
||||
}
|
||||
|
||||
|
||||
////Jump & Gravity Calculations
|
||||
//Uses Given gravity to apply a downwards force while allowing coyote Jump and short hops
|
||||
public void GravityCalculation(float grav){
|
||||
if(moveController.enabled){
|
||||
@@ -126,7 +202,7 @@ public class AerialStateManager : MonoBehaviour
|
||||
}
|
||||
|
||||
//apply gravity if not grounded and coyote timer is less than 0
|
||||
if((isGrounded == false && curCoyJumpTimer <= 0)/* || grapple.isGrappled*/){
|
||||
if((isGrounded == false && curCoyJumpTimer <= 0) || currentState == GrappleAirState){
|
||||
pStats.GravVel -= grav * Time.deltaTime;
|
||||
}
|
||||
//else don't apply gravity
|
||||
@@ -157,7 +233,7 @@ public class AerialStateManager : MonoBehaviour
|
||||
{
|
||||
isGrounded = true;
|
||||
// handle snapping to the ground
|
||||
if (groundHit.distance > moveController.skinWidth /* && !grapple.isGrappled*/)
|
||||
if (groundHit.distance > moveController.skinWidth && currentState != GrappleAirState)
|
||||
{
|
||||
moveController.Move(Vector3.down * groundHit.distance);
|
||||
}
|
||||
@@ -165,17 +241,34 @@ public class AerialStateManager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private void DownwardMovement(){
|
||||
//Actually applies the downwards movement
|
||||
void DownwardMovement(){
|
||||
Vector3 moveY = new Vector3(0,pStats.GravVel,0) * Time.deltaTime;
|
||||
|
||||
|
||||
|
||||
if(currentState == GrappleAirState){
|
||||
moveY = (new Vector3(0,pStats.GravVel,0) + forceDirection) * Time.deltaTime;
|
||||
}
|
||||
|
||||
moveController.Move(moveY);
|
||||
|
||||
}
|
||||
|
||||
private void Jump(){
|
||||
//applies Jump values and Variables
|
||||
void Jump(){
|
||||
//If space/south gamepad button is pressed apply an upwards force to the player
|
||||
if (Input.GetAxis("Jump") != 0 && !jumpHeld && curJumpNum < pStats.JumpNum)
|
||||
{
|
||||
pStats.GravVel = pStats.JumpPow;
|
||||
if(currentState == WallRunState){
|
||||
AddImpact((GetWallJumpDirection()), pStats.JumpPow * 8.5f);
|
||||
pStats.GravVel = pStats.JumpPow;
|
||||
curJumpNum = 0;
|
||||
}
|
||||
else{
|
||||
pStats.GravVel = pStats.JumpPow;
|
||||
}
|
||||
|
||||
|
||||
curJumpNum++;
|
||||
jumpHeld = true;
|
||||
@@ -203,25 +296,211 @@ public class AerialStateManager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
//Wallrunning
|
||||
else if (pStats.HasWallrun) {
|
||||
//Run wall run script
|
||||
wallRun.WallRunRoutine();
|
||||
//Apply Impact for when force needs to be applied without ragdolling
|
||||
public void AddImpact(Vector3 dir, float force){
|
||||
//if (!IsLocalPlayer) { return; }
|
||||
|
||||
//if wallrunning apply different gravity
|
||||
if(wallRun.IsWallRunning()){
|
||||
if(wallRun.firstAttach){
|
||||
g = 0;
|
||||
wallRun.firstAttach = false;
|
||||
}
|
||||
GravityCalculation(2);
|
||||
//Normalize direction multiply by force and add it to the impact
|
||||
dir.Normalize();
|
||||
if (dir.y < 0) dir.y = -dir.y; // reflect down force on the ground
|
||||
impact += dir.normalized * force / mass;
|
||||
}
|
||||
|
||||
//Dissipates Impact Force
|
||||
void DissipateImpact(){
|
||||
//if suffiecient impact magnitude is applied then move player
|
||||
if (impact.magnitude > 0.2F) moveController.Move(impact * Time.deltaTime);
|
||||
|
||||
// consumes the impact energy each cycle:
|
||||
impact = Vector3.Lerp(impact, Vector3.zero, 5*Time.deltaTime);
|
||||
}
|
||||
////
|
||||
|
||||
////Wallrun Functions
|
||||
//Checks if they can wallrun
|
||||
public bool CanWallRun(){
|
||||
float verticalAxis = Input.GetAxisRaw("Vertical");
|
||||
return !isGrounded && verticalAxis > 0 && !Physics.Raycast(transform.position, Vector3.down, minimumHeight);
|
||||
}
|
||||
|
||||
//checks if they can attach
|
||||
bool CanAttach(){
|
||||
if(jumping)
|
||||
{
|
||||
elapsedTimeSinceJump += Time.deltaTime;
|
||||
if(elapsedTimeSinceJump > jumpDuration)
|
||||
{
|
||||
elapsedTimeSinceJump = 0;
|
||||
jumping = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//On Wall calulations
|
||||
void OnWall(RaycastHit hit){
|
||||
float d = Vector3.Dot(hit.normal, Vector3.up);
|
||||
if(d >= -normalizedAngleThreshold && d <= normalizedAngleThreshold)
|
||||
{
|
||||
Vector3 alongWall = Vector3.Cross(hit.normal, Vector3.up);
|
||||
float vertical = Input.GetAxisRaw("Vertical");
|
||||
//Vector3 alongWall = transform.TransformDirection(Vector3.forward);
|
||||
|
||||
// Debug.DrawRay(transform.position, alongWall.normalized * 10, Color.green);
|
||||
// Debug.DrawRay(transform.position, lastWallNormal * 10, Color.magenta);
|
||||
|
||||
Vector3 moveToSet = alongWall * vertical * mSM.PlayerSpeed() * Time.deltaTime;
|
||||
Vector3 velNorm = mSM.vel;
|
||||
velNorm.Normalize();
|
||||
|
||||
moveToSet = new Vector3(moveToSet.x * -velNorm.x, moveToSet.y, moveToSet.z * -velNorm.z);
|
||||
|
||||
Vector3 moveToSetNorm = moveToSet;
|
||||
moveToSetNorm.Normalize();
|
||||
|
||||
if((moveToSetNorm.x < 0 && velNorm.x > 0)){
|
||||
moveToSet.x = (moveToSet.x * -velNorm.x);
|
||||
}
|
||||
else if((moveToSetNorm.x > 0 && velNorm.x < 0) ){
|
||||
moveToSet.x = (-moveToSet.x * -velNorm.x);
|
||||
}
|
||||
|
||||
//Normal gravity if not wallrunning
|
||||
else{
|
||||
GravityCalculation(pStats.PlayerGrav);
|
||||
if((moveToSetNorm.z < 0 && velNorm.z > 0)){
|
||||
moveToSet.z = (moveToSet.z * -velNorm.z);
|
||||
}
|
||||
else if((moveToSetNorm.z > 0 && velNorm.z < 0)){
|
||||
moveToSet.z = (-moveToSet.z * -velNorm.z);
|
||||
}
|
||||
|
||||
moveToSet.y = 0;
|
||||
//
|
||||
|
||||
mSM.vel = moveToSet;
|
||||
if(!isWallRunning){
|
||||
isWallRunning = true;
|
||||
}
|
||||
|
||||
if(curJumpNum == mSM.pStats.JumpNum){
|
||||
curJumpNum = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Calculate wall direction
|
||||
float CalculateSide(){
|
||||
if(isWallRunning)
|
||||
{
|
||||
Vector3 heading = lastWallPosition - transform.position;
|
||||
Vector3 perp = Vector3.Cross(transform.forward, heading);
|
||||
float dir = Vector3.Dot(perp, transform.up);
|
||||
return dir;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//The Wallrun Routine itself
|
||||
void WallRunRoutine(){
|
||||
//if (!IsLocalPlayer) { return; }
|
||||
|
||||
isWallRunning = false;
|
||||
|
||||
hits = new RaycastHit[directions.Length];
|
||||
|
||||
if(jumpHeld)
|
||||
{
|
||||
jumping = true;
|
||||
}
|
||||
|
||||
if(CanAttach())
|
||||
{
|
||||
for(int i=0; i<directions.Length; i++)
|
||||
{
|
||||
Vector3 dir = transform.TransformDirection(directions[i]);
|
||||
Physics.Raycast(transform.position, dir, out hits[i], wallMaxDistance);
|
||||
if(hits[i].collider != null)
|
||||
{
|
||||
Debug.DrawRay(transform.position, dir * hits[i].distance, Color.green);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.DrawRay(transform.position, dir * wallMaxDistance, Color.red);
|
||||
}
|
||||
}
|
||||
|
||||
if(CanWallRun())
|
||||
{
|
||||
hits = hits.ToList().Where(h => h.collider != null).OrderBy(h => h.distance).ToArray();
|
||||
if(hits.Length > 0)
|
||||
{
|
||||
if(hits[0].collider.tag == "WallRun")
|
||||
{
|
||||
OnWall(hits[0]);
|
||||
lastWallPosition = hits[0].point;
|
||||
lastWallNormal = hits[0].normal;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if(isWallRunning)
|
||||
{
|
||||
elapsedTimeSinceWallDetatch = 0;
|
||||
elapsedTimeSinceWallAttach += Time.deltaTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
elapsedTimeSinceWallAttach = 0;
|
||||
elapsedTimeSinceWallDetatch += Time.deltaTime;
|
||||
}
|
||||
}
|
||||
|
||||
//The Direction the player jumps on wall detachment
|
||||
public Vector3 GetWallJumpDirection(){
|
||||
return lastWallNormal * wallBouncing + (transform.up);
|
||||
}
|
||||
////
|
||||
|
||||
////Grapple Functions
|
||||
//Checks if the player can grapple
|
||||
public bool CheckGrapple(){
|
||||
if ((Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton2)) && pStats.HasGrapple) //If grapple button is hit
|
||||
{
|
||||
hookPointIndex = FindHookPoint(); //Find the nearest hook point within max distance
|
||||
if (hookPointIndex != -1) //If there is a hookpoint
|
||||
{
|
||||
hookPoint = hookPoints[hookPointIndex]; //The point we are grappling from
|
||||
eHeld = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//Finds the nearest hook to the player
|
||||
int FindHookPoint()
|
||||
{
|
||||
float least = maxGrabDistance;
|
||||
int index = -1;
|
||||
for(int i = 0; i<hookPoints.Length; i++)
|
||||
{
|
||||
distance = Vector3.Distance(gameObject.transform.position, hookPoints[i].transform.position);
|
||||
if (distance <= least)
|
||||
{
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
public void GrappleReleaseForce(){
|
||||
if(release){
|
||||
lerpRelease = Vector3.Lerp(lerpRelease, tempRelease, 9f * Time.deltaTime);
|
||||
tempRelease *= .98f;
|
||||
moveController.Move(lerpRelease);
|
||||
}
|
||||
}
|
||||
////
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d9e7839f6deda248905235a2cc3e3cf
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,228 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AerialGrappleAirState : AerialBaseState
|
||||
{
|
||||
float ropeLength; // current rope length
|
||||
Vector3 swingDirection; // Swing direction
|
||||
float inclinationAngle; // inclination angle
|
||||
float theta = -1; // theta
|
||||
float swingMom;
|
||||
Vector3 tensionMomDirection;
|
||||
Vector3 hookPointRight;
|
||||
Vector3 momDirection;
|
||||
Vector3 curXZDir;
|
||||
Vector3 oldXZDir;
|
||||
float swingSpeed = 10;
|
||||
bool swingback = false; //swing the player back
|
||||
float oldSwingMom;
|
||||
Vector3 tensionDirection;
|
||||
float tensionForce;
|
||||
|
||||
public override void EnterState(AerialStateManager aSM, AerialBaseState previousState){
|
||||
|
||||
Debug.Log("Grapple Air State");
|
||||
|
||||
aSM.curJumpNum = 0;
|
||||
|
||||
ropeLength = Vector3.Distance(aSM.transform.position, aSM.hookPoint.transform.position);
|
||||
if(ropeLength > aSM.maxGrappleDistance){
|
||||
ropeLength = aSM.maxGrappleDistance;
|
||||
}
|
||||
|
||||
oldXZDir = (new Vector3(aSM.hookPoint.transform.position.x,0,aSM.hookPoint.transform.position.z) - new Vector3(aSM.transform.position.x,0,aSM.transform.position.z)).normalized;
|
||||
curXZDir = (new Vector3(aSM.hookPoint.transform.position.x,0,aSM.hookPoint.transform.position.z) - new Vector3(aSM.transform.position.x,0,aSM.transform.position.z)).normalized;
|
||||
|
||||
swingMom = CalculateSwingMom(aSM.mSM.driftVel.magnitude * 50f, aSM);
|
||||
oldSwingMom = swingMom;
|
||||
aSM.pStats.GravVel = -1;
|
||||
aSM.release = false;
|
||||
aSM.lerpRelease = Vector3.zero;
|
||||
}
|
||||
|
||||
public override void ExitState(AerialStateManager aSM, AerialBaseState nextState){
|
||||
if(nextState != aSM.GrappleGroundedState){
|
||||
aSM.release = true;
|
||||
aSM.pStats.GravVel = 0;
|
||||
aSM.forceDirection = Vector3.zero;
|
||||
swingback = true;
|
||||
}
|
||||
else{
|
||||
aSM.pStats.GravVel = 0;
|
||||
aSM.forceDirection = Vector3.zero;
|
||||
swingback = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateState(AerialStateManager aSM){
|
||||
|
||||
if((Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton2)) && !aSM.eHeld){
|
||||
aSM.SwitchState(aSM.FallingState);
|
||||
}
|
||||
else if((Input.GetKeyUp(KeyCode.E) || Input.GetKeyUp(KeyCode.JoystickButton2))){
|
||||
aSM.eHeld = false;
|
||||
}
|
||||
|
||||
if(Input.GetButton("Jump")){
|
||||
|
||||
aSM.SwitchState(aSM.JumpingState);
|
||||
}
|
||||
|
||||
if(aSM.isGrounded){
|
||||
aSM.SwitchState(aSM.GrappleGroundedState);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(AerialStateManager aSM){
|
||||
|
||||
Debug.DrawRay(aSM.transform.position, (aSM.hookPoint.transform.position - aSM.transform.position)); //Visual of line
|
||||
|
||||
//Debug.Log(Vector3.Distance(gameObject.transform.position, hookPoint.transform.position));
|
||||
//Calculate tether force direction based on hookpoint
|
||||
if (Vector3.Distance(aSM.transform.position, aSM.hookPoint.transform.position) >= ropeLength )
|
||||
{
|
||||
aSM.forceDirection = CalculateForceDirection(1, aSM.pStats.GravVel, aSM.hookPoint.transform.position, aSM) + RopeLengthOffset(aSM.hookPoint.transform.position, Vector3.Distance(aSM.transform.position, aSM.hookPoint.transform.position), aSM);
|
||||
}
|
||||
else{
|
||||
aSM.forceDirection = Vector3.zero;
|
||||
}
|
||||
|
||||
aSM.moveController.Move(SwingMoveController(aSM));
|
||||
if(swingMom != 0){
|
||||
aSM.moveController.Move(CalculateMomentumDirection(aSM.pStats.GravVel, aSM.hookPoint.transform.position, aSM));
|
||||
swingMom -= .5f;
|
||||
}
|
||||
|
||||
if(swingMom<0) swingMom = 0;
|
||||
|
||||
aSM.tempRelease = CalculateSwingReleaseForce();
|
||||
aSM.GravityCalculation(aSM.pStats.PlayerGrav);
|
||||
}
|
||||
|
||||
//Needs to be Overhauled to properly implement energy loss taking into account players current Velocity, height and input
|
||||
//------Important Equations--------
|
||||
// TensionForce = Cos(theta) * g * m * Vector3(tensionDirection)
|
||||
// Potential Energy = m * g * h -- Will need to modify adding current speed
|
||||
// Kinetic Energy = 1/2 * m * V^2 -- assuming no energy loss at the bottom KE = PE at peak we will add energy loss ourselves
|
||||
// Total Energy = m * ((g*h) + (1/2 * V^2))
|
||||
// Velocity = (2 * ((TotalEnergy/m) - (g*h)))^(1/2) -- This hypothetically could be used for our swing momentum calculation
|
||||
// Movement Direction right angle of tension force = Sin(theta) * g * m * Vector3(Right angle to tensionDirection)
|
||||
|
||||
//Calculate the tether direction vector and how much force that vector needs
|
||||
Vector3 CalculateForceDirection(float mass, float g, Vector3 hPoint, AerialStateManager aSM){
|
||||
|
||||
//tension direction and angle calculation
|
||||
tensionDirection = (hPoint - aSM.transform.position).normalized;
|
||||
inclinationAngle = Vector3.Angle((aSM.transform.position - hPoint).normalized, -aSM.transform.up);
|
||||
theta = Mathf.Deg2Rad * inclinationAngle;
|
||||
if(theta<=.1) theta = 0;
|
||||
|
||||
//How much force the tension needs
|
||||
tensionForce = mass * -g * Mathf.Cos(theta);
|
||||
|
||||
//force direction calculation based on tension direction and force
|
||||
Vector3 fDirection = tensionDirection * tensionForce;
|
||||
return fDirection;
|
||||
}
|
||||
|
||||
Vector3 CalculateMomentumDirection(float g, Vector3 hPoint, AerialStateManager aSM){
|
||||
|
||||
tensionMomDirection = (hPoint - aSM.transform.position).normalized;
|
||||
hookPointRight = Vector3.Cross(oldXZDir, aSM.transform.up).normalized;
|
||||
momDirection = -1 * Vector3.Cross(hookPointRight, tensionMomDirection).normalized;
|
||||
|
||||
if(oldXZDir != curXZDir){
|
||||
//midpointMom = swingMom;
|
||||
swingback = false;
|
||||
//Debug.Log("flip");
|
||||
}
|
||||
|
||||
if(swingback == false && swingMom <= (oldSwingMom*(.75f))){
|
||||
swingback = true;
|
||||
oldSwingMom = swingMom;
|
||||
oldXZDir = (new Vector3(aSM.hookPoint.transform.position.x,0,aSM.hookPoint.transform.position.z) - new Vector3(aSM.transform.position.x,0,aSM.transform.position.z)).normalized;
|
||||
//Debug.Log("swingback");
|
||||
}
|
||||
|
||||
curXZDir = (new Vector3(hPoint.x,0,hPoint.z) - new Vector3(aSM.transform.position.x,0,aSM.transform.position.z)).normalized;
|
||||
Debug.DrawRay(aSM.transform.position, momDirection * Time.deltaTime* 100, Color.green);
|
||||
return (momDirection * Time.deltaTime * swingMom);
|
||||
}
|
||||
|
||||
//Calculates the players initial swing momentum using their height and their current velocity
|
||||
float CalculateSwingMom(float playerSpeed, AerialStateManager aSM){
|
||||
|
||||
//Calculate the players height compared to the lowest point in the swing
|
||||
float swingHeight = aSM.transform.position.y - (aSM.hookPoint.transform.position.y - ropeLength);
|
||||
if(swingHeight <= 1){
|
||||
swingHeight = 1;
|
||||
}
|
||||
|
||||
float sMom = playerSpeed + (swingHeight*2);
|
||||
if(sMom > aSM.maxSwingMom){
|
||||
sMom = aSM.maxSwingMom;
|
||||
}
|
||||
return sMom;
|
||||
}
|
||||
|
||||
//Special movement for the player while they swing
|
||||
Vector3 SwingMoveController(AerialStateManager aSM){
|
||||
|
||||
//WASD input
|
||||
float inputVert = Input.GetAxis("Vertical");
|
||||
float inputHor = Input.GetAxis("Horizontal");
|
||||
|
||||
//input is zero when nothing is pressed to prevent button easing values
|
||||
if((!Input.GetKey(KeyCode.W) && !Input.GetKey(KeyCode.S))) inputVert = 0;
|
||||
if((!Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.D))) inputHor = 0;
|
||||
|
||||
//Swingspeed build up
|
||||
if((inputVert != 0 || inputHor != 0) && swingSpeed < aSM.maxSwingSpeed){
|
||||
swingSpeed += aSM.swingAcc;
|
||||
}
|
||||
else if((inputVert != 0 || inputHor != 0) && swingSpeed >= aSM.maxSwingSpeed){
|
||||
swingSpeed = aSM.maxSwingSpeed;
|
||||
}
|
||||
else if((inputVert == 0 && inputHor == 0)){
|
||||
swingSpeed = aSM.minSwingSpeed;
|
||||
}
|
||||
|
||||
//Swing direction based on player input
|
||||
swingDirection = Vector3.Cross(tensionDirection, ((aSM.transform.right * -inputVert) + (aSM.transform.forward * inputHor))).normalized;
|
||||
|
||||
|
||||
//NEED TO ADD SWINGSPEED EASING
|
||||
//this could be just adding a gradual increase in the swing speed instead of using a flat rate
|
||||
//Swing movement with swing speed added
|
||||
Vector3 swingMovement = (swingDirection * Time.deltaTime * swingSpeed);
|
||||
|
||||
|
||||
return (swingMovement);
|
||||
}
|
||||
|
||||
Vector3 RopeLengthOffset(Vector3 hPoint, float curDistance, AerialStateManager aSM){
|
||||
|
||||
//How powerful our offset movement has to be
|
||||
float offsetPower = ((curDistance - ropeLength) * 200f);
|
||||
|
||||
//The direction we need to apply force to offset when the rope gets lengthened beyond the necessary point
|
||||
Vector3 tenDirOffset = (hPoint - aSM.transform.position).normalized;
|
||||
|
||||
|
||||
return tenDirOffset * offsetPower * Time.deltaTime;
|
||||
}
|
||||
|
||||
Vector3 CalculateSwingReleaseForce(){
|
||||
|
||||
Vector3 releaseSwingForceDirection = momDirection * ((swingMom) + 10);
|
||||
|
||||
releaseSwingForceDirection = new Vector3(releaseSwingForceDirection.x,0,releaseSwingForceDirection.z);
|
||||
|
||||
if(swingMom < 5){
|
||||
return Vector3.zero;
|
||||
}
|
||||
return releaseSwingForceDirection * Time.deltaTime;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 18f636cc4d77c0d439a1effaa5b08485
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AerialGrappleGroundedState : AerialBaseState
|
||||
{
|
||||
public override void EnterState(AerialStateManager aSM, AerialBaseState previousState){
|
||||
Debug.Log("Grapple Grounded State");
|
||||
|
||||
aSM.release = false;
|
||||
}
|
||||
|
||||
public override void ExitState(AerialStateManager aSM, AerialBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(AerialStateManager aSM){
|
||||
if(!aSM.isGrounded && aSM.pStats.GravVel < 0){
|
||||
aSM.SwitchState(aSM.GrappleAirState);
|
||||
}
|
||||
|
||||
if(Vector3.Distance(aSM.transform.position, aSM.hookPoint.transform.position) > aSM.maxGrappleDistance){
|
||||
aSM.SwitchState(aSM.GroundedState);
|
||||
}
|
||||
|
||||
if((Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton2)) && !aSM.eHeld){
|
||||
aSM.SwitchState(aSM.GroundedState);
|
||||
}
|
||||
else if((Input.GetKeyUp(KeyCode.E) || Input.GetKeyUp(KeyCode.JoystickButton2))){
|
||||
aSM.eHeld = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(AerialStateManager aSM){
|
||||
Debug.DrawRay(aSM.transform.position, (aSM.hookPoint.transform.position - aSM.transform.position)); //Visual of line
|
||||
|
||||
aSM.GravityCalculation(aSM.pStats.PlayerGrav);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bd53fea25f9a40e41812e6faae369b2a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7bdb37848afbcd446b59b3158927a111
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,23 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AerialWallIdleState : AerialBaseState
|
||||
{
|
||||
|
||||
public override void EnterState(AerialStateManager aSM, AerialBaseState previousState){
|
||||
|
||||
}
|
||||
|
||||
public override void ExitState(AerialStateManager aSM, AerialBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(AerialStateManager aSM){
|
||||
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(AerialStateManager aSM){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 15b109cc50982684c9d17a41ec11dc32
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,34 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AerialWallRunState : AerialBaseState
|
||||
{
|
||||
|
||||
public override void EnterState(AerialStateManager aSM, AerialBaseState previousState){
|
||||
Debug.Log("Wallrun State");
|
||||
aSM.pStats.GravVel = 0;
|
||||
|
||||
}
|
||||
|
||||
public override void ExitState(AerialStateManager aSM, AerialBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(AerialStateManager aSM){
|
||||
if(Input.GetButton("Jump")){
|
||||
aSM.SwitchState(aSM.JumpingState);
|
||||
}
|
||||
else if(!aSM.isWallRunning){
|
||||
aSM.SwitchState(aSM.FallingState);
|
||||
}
|
||||
|
||||
if(aSM.CheckGrapple() && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
|
||||
aSM.SwitchState(aSM.GrappleAirState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(AerialStateManager aSM){
|
||||
aSM.GravityCalculation(2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93ab0a7ac87da66408ced3667ae9b930
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2a3e1f7f578e18f408e5ae9b97d27942
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DashCooldownState : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bad22bcf005335b43bc4ca573461d7ab
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DashDashingState : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b41f7d4ad84f9143bb3b8f570ee7505
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DashIncapacitatedState : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 603d43aaa9b286a43a78312d03135afe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DashNoneState : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8b1f874d79f4e64ea90f162d3cf01eb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class DashBaseState
|
||||
{
|
||||
public abstract void EnterState(DashStateManager dSM, DashBaseState previousState);
|
||||
public abstract void ExitState(DashStateManager dSM, DashBaseState nextState);
|
||||
public abstract void UpdateState(DashStateManager dSM);
|
||||
public abstract void FixedUpdateState(DashStateManager dSM);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 672ce2f99c12e8e449bbd8a3238e601d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,33 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DashStateManager : MonoBehaviour
|
||||
{
|
||||
////Player States
|
||||
public DashBaseState currentState;
|
||||
public DashBaseState previousState;
|
||||
|
||||
//Dash States
|
||||
public DashNoneState NoneState = new DashNoneState();
|
||||
public DashIncapacitatedState IncapacitatedState = new DashIncapacitatedState();
|
||||
public DashCooldownState CooldownState = new DashCooldownState();
|
||||
////
|
||||
|
||||
////Objects Sections
|
||||
GameObject parentObj; // Parent object
|
||||
public Camera cam; // Camera object
|
||||
////
|
||||
|
||||
////Components Section
|
||||
public CharacterController moveController; // Character Controller
|
||||
Rigidbody rB; // Players Rigidbody
|
||||
CapsuleCollider capCol; // Players Capsule Collider
|
||||
Animator animator; // Animation Controller
|
||||
////
|
||||
|
||||
////Scripts Section
|
||||
public PlayerStats pStats; // Player Stats
|
||||
public MoveStateManager mSM;
|
||||
////
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5904903ff376f25499c08e24ad00aaf8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,34 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MoveGrappleAirState : MoveBaseState
|
||||
{
|
||||
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
|
||||
mSM.driftVel = Vector3.zero;
|
||||
}
|
||||
|
||||
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(MoveStateManager mSM){
|
||||
if(mSM.aSM.currentState != mSM.aSM.GrappleAirState){
|
||||
//Determine which state to go into based on player speed
|
||||
if(mSM.calculatedCurVel < mSM.walkLimit){
|
||||
mSM.SwitchState(mSM.WalkState);
|
||||
}
|
||||
else if(mSM.calculatedCurVel < mSM.runLimit){
|
||||
mSM.SwitchState(mSM.JogState);
|
||||
}
|
||||
else{
|
||||
mSM.SwitchState(mSM.RunState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(MoveStateManager mSM){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef1fdba284bf4db40903d97f11507813
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -8,7 +8,7 @@ public class MoveRagdollState : MoveBaseState
|
||||
Vector3 prevRot;
|
||||
bool beginRagTimer = false;
|
||||
|
||||
public override void EnterState(MoveStateManager mSM){
|
||||
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
|
||||
Debug.Log("Ragdoll State");
|
||||
|
||||
ragTime = mSM.pStats.RecovTime;
|
||||
@@ -21,6 +21,15 @@ public class MoveRagdollState : MoveBaseState
|
||||
mSM.rB.AddForce(mSM.dirHit, ForceMode.Impulse);
|
||||
}
|
||||
|
||||
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
|
||||
mSM.pStats.GravVel = 50;
|
||||
mSM.capCol.enabled = false;
|
||||
mSM.moveController.enabled = true;
|
||||
mSM.rB.isKinematic = true;
|
||||
mSM.rB.detectCollisions = false;
|
||||
mSM.transform.localEulerAngles = prevRot;
|
||||
}
|
||||
|
||||
public override void UpdateState(MoveStateManager mSM){
|
||||
if(!beginRagTimer){
|
||||
beginRagTimer = Physics.Raycast(mSM.transform.position, -Vector3.up, mSM.distToGround + 1f);
|
||||
@@ -36,17 +45,7 @@ public class MoveRagdollState : MoveBaseState
|
||||
ragTime = 0;
|
||||
beginRagTimer = false;
|
||||
|
||||
mSM.pStats.GravVel = 50;
|
||||
mSM.capCol.enabled = false;
|
||||
mSM.moveController.enabled = true;
|
||||
mSM.rB.isKinematic = true;
|
||||
mSM.rB.detectCollisions = false;
|
||||
mSM.transform.localEulerAngles = prevRot;
|
||||
mSM.SwitchState(mSM.RecoveringState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnCollisionEnter(MoveStateManager mSM){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,14 @@ public class MoveRecoveringState : MoveBaseState
|
||||
{
|
||||
////// ADD SOMETHING THAT CHECKS ANIMATION FINISH BEFORE GO TO IDLE
|
||||
|
||||
public override void EnterState(MoveStateManager mSM){
|
||||
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
|
||||
mSM.CancelMomentum();
|
||||
}
|
||||
|
||||
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(MoveStateManager mSM){
|
||||
mSM.SwitchState(mSM.IdleState);
|
||||
}
|
||||
@@ -17,8 +21,4 @@ public class MoveRecoveringState : MoveBaseState
|
||||
public override void FixedUpdateState(MoveStateManager mSM){
|
||||
|
||||
}
|
||||
|
||||
public override void OnCollisionEnter(MoveStateManager mSM){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,8 @@ using UnityEngine;
|
||||
|
||||
public abstract class MoveBaseState
|
||||
{
|
||||
public abstract void EnterState(MoveStateManager mSM);
|
||||
public abstract void EnterState(MoveStateManager mSM, MoveBaseState previousState);
|
||||
public abstract void ExitState(MoveStateManager mSM, MoveBaseState nextState);
|
||||
public abstract void UpdateState(MoveStateManager mSM);
|
||||
public abstract void FixedUpdateState(MoveStateManager mSM);
|
||||
public abstract void OnCollisionEnter(MoveStateManager mSM);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,9 @@ public class MoveStateManager : MonoBehaviour
|
||||
//Incapitated States
|
||||
public MoveRagdollState RagdollState = new MoveRagdollState();
|
||||
public MoveRecoveringState RecoveringState = new MoveRecoveringState();
|
||||
|
||||
//Grapple States
|
||||
public MoveGrappleAirState GrappleAirState = new MoveGrappleAirState();
|
||||
////
|
||||
|
||||
////Objects Sections
|
||||
@@ -69,12 +72,8 @@ public class MoveStateManager : MonoBehaviour
|
||||
public int sensitivity = 200; // Camera sensitivity
|
||||
|
||||
//Ragdoll Variables
|
||||
public Vector3 dirHit;
|
||||
public Vector3 dirHit; // Direction hit
|
||||
public float distToGround; // distance to ground
|
||||
|
||||
//Impact Variables
|
||||
private float mass = 5.0F; // mass variable for Impact
|
||||
private Vector3 impact = Vector3.zero; // Impact Vector
|
||||
////
|
||||
|
||||
|
||||
@@ -101,7 +100,7 @@ public class MoveStateManager : MonoBehaviour
|
||||
//players starting state
|
||||
currentState = IdleState;
|
||||
previousState = IdleState;
|
||||
currentState.EnterState(this);
|
||||
currentState.EnterState(this, previousState);
|
||||
|
||||
//Slide Upwards Variable
|
||||
slideUp = GetComponentInParent<Transform>().up; // get parents up direction
|
||||
@@ -116,6 +115,8 @@ public class MoveStateManager : MonoBehaviour
|
||||
//calculates vel using driftVel will need to be relocated
|
||||
calculatedCurVel = driftVel.magnitude * 50f;
|
||||
|
||||
GoToGrapple();
|
||||
|
||||
//calls any logic in the update state from current state
|
||||
currentState.UpdateState(this);
|
||||
}
|
||||
@@ -131,12 +132,14 @@ public class MoveStateManager : MonoBehaviour
|
||||
|
||||
public void SwitchState(MoveBaseState state){
|
||||
|
||||
currentState.ExitState(this, state);
|
||||
|
||||
//Sets the previous State
|
||||
previousState = currentState;
|
||||
|
||||
//updates current state and calls logic for entering
|
||||
currentState = state;
|
||||
currentState.EnterState(this);
|
||||
currentState.EnterState(this, previousState);
|
||||
}
|
||||
|
||||
|
||||
@@ -252,4 +255,9 @@ public class MoveStateManager : MonoBehaviour
|
||||
driftVel = Vector3.zero;
|
||||
}
|
||||
|
||||
void GoToGrapple(){
|
||||
if(aSM.currentState == aSM.GrappleAirState && (currentState != SlideState && currentState != RagdollState && currentState != RecoveringState)){
|
||||
SwitchState(GrappleAirState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,10 @@ public class MoveCrouchState : MoveBaseState
|
||||
float originalTraction; // Traction before slide started
|
||||
RaycastHit slideRay; // slide raycast
|
||||
|
||||
public override void EnterState(MoveStateManager mSM){
|
||||
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
|
||||
Debug.Log("Crouch State");
|
||||
|
||||
if(mSM.previousState != mSM.SlideState){
|
||||
if(previousState != mSM.SlideState){
|
||||
//Initialize Important Stats On state enter
|
||||
mSM.pStats.CurVel = 0;
|
||||
originalTraction = mSM.pStats.Traction;
|
||||
@@ -22,6 +22,16 @@ public class MoveCrouchState : MoveBaseState
|
||||
}
|
||||
}
|
||||
|
||||
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
|
||||
if(nextState != mSM.CrouchWalkState){
|
||||
mSM.gameObject.transform.localEulerAngles = new Vector3(0, 0, 0);
|
||||
mSM.pStats.CurVel = mSM.calculatedCurVel;
|
||||
mSM.pStats.Traction = originalTraction;
|
||||
mSM.moveController.height *= 2.0f;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(MoveStateManager mSM){
|
||||
|
||||
}
|
||||
@@ -35,7 +45,6 @@ public class MoveCrouchState : MoveBaseState
|
||||
if((!Input.GetKey(KeyCode.JoystickButton1) && !Input.GetKey(KeyCode.Q))){
|
||||
if ((Physics.Raycast(mSM.gameObject.transform.position, mSM.slideUp, out slideRay, 5f) == false)){
|
||||
|
||||
ExitCrouchState(mSM);
|
||||
mSM.SwitchState(mSM.IdleState);
|
||||
}
|
||||
else{
|
||||
@@ -52,15 +61,4 @@ public class MoveCrouchState : MoveBaseState
|
||||
*/
|
||||
mSM.SlideMovement();
|
||||
}
|
||||
|
||||
public override void OnCollisionEnter(MoveStateManager mSM){
|
||||
|
||||
}
|
||||
|
||||
public void ExitCrouchState(MoveStateManager mSM){
|
||||
mSM.gameObject.transform.localEulerAngles = new Vector3(0, 0, 0);
|
||||
mSM.pStats.CurVel = mSM.calculatedCurVel;
|
||||
mSM.pStats.Traction = originalTraction;
|
||||
mSM.moveController.height *= 2.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,13 @@ using UnityEngine;
|
||||
|
||||
public class MoveCrouchWalkState : MoveBaseState
|
||||
{
|
||||
public override void EnterState(MoveStateManager mSM){
|
||||
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
|
||||
Debug.Log("Crouch Walk State");
|
||||
}
|
||||
|
||||
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(MoveStateManager mSM){
|
||||
|
||||
@@ -33,7 +37,4 @@ public class MoveCrouchWalkState : MoveBaseState
|
||||
*/
|
||||
}
|
||||
|
||||
public override void OnCollisionEnter(MoveStateManager mSM){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ public class MoveSlideState : MoveBaseState
|
||||
float originalTraction; // Traction before slide started
|
||||
RaycastHit slideRay; // slide raycast
|
||||
|
||||
public override void EnterState(MoveStateManager mSM){
|
||||
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
|
||||
Debug.Log("Slide State");
|
||||
|
||||
//Initialize Important Stats On state enter
|
||||
@@ -19,6 +19,15 @@ public class MoveSlideState : MoveBaseState
|
||||
mSM.pStats.Traction = 0.01f;
|
||||
}
|
||||
|
||||
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
|
||||
if(nextState != mSM.CrouchState){
|
||||
mSM.gameObject.transform.localEulerAngles = new Vector3(0, 0, 0);
|
||||
mSM.pStats.CurVel = mSM.calculatedCurVel;
|
||||
mSM.pStats.Traction = originalTraction;
|
||||
mSM.moveController.height *= 2.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateState(MoveStateManager mSM){
|
||||
|
||||
//if player comes to a stop while sliding they crouch
|
||||
@@ -38,15 +47,12 @@ public class MoveSlideState : MoveBaseState
|
||||
|
||||
//Determine which state to go into based on player speed
|
||||
if(mSM.calculatedCurVel < mSM.walkLimit){
|
||||
SlideToMoveState(mSM);
|
||||
mSM.SwitchState(mSM.WalkState);
|
||||
}
|
||||
else if(mSM.calculatedCurVel < mSM.runLimit){
|
||||
SlideToMoveState(mSM);
|
||||
mSM.SwitchState(mSM.JogState);
|
||||
}
|
||||
else{
|
||||
SlideToMoveState(mSM);
|
||||
mSM.SwitchState(mSM.RunState);
|
||||
}
|
||||
}
|
||||
@@ -76,15 +82,4 @@ public class MoveSlideState : MoveBaseState
|
||||
*/
|
||||
mSM.SlideMovement();
|
||||
}
|
||||
|
||||
public override void OnCollisionEnter(MoveStateManager mSM){
|
||||
|
||||
}
|
||||
|
||||
public void SlideToMoveState(MoveStateManager mSM){
|
||||
mSM.gameObject.transform.localEulerAngles = new Vector3(0, 0, 0);
|
||||
mSM.pStats.CurVel = mSM.calculatedCurVel;
|
||||
mSM.pStats.Traction = originalTraction;
|
||||
mSM.moveController.height *= 2.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,14 @@ using UnityEngine;
|
||||
|
||||
public class MoveIdleState : MoveBaseState
|
||||
{
|
||||
public override void EnterState(MoveStateManager mSM){
|
||||
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
|
||||
Debug.Log("Idle State");
|
||||
}
|
||||
|
||||
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(MoveStateManager mSM){
|
||||
|
||||
//Move to Walk State after speed increases
|
||||
@@ -16,7 +20,7 @@ public class MoveIdleState : MoveBaseState
|
||||
}
|
||||
|
||||
//If Q or joystick button1 crouch state
|
||||
if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && mSM.aSM.currentState != mSM.aSM.FallingState){
|
||||
if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && (mSM.aSM.currentState != mSM.aSM.FallingState && mSM.aSM.currentState != mSM.aSM.WallRunState && mSM.aSM.currentState != mSM.aSM.WallIdleState && mSM.aSM.currentState != mSM.aSM.GrappleGroundedState)){
|
||||
mSM.SwitchState(mSM.CrouchState);
|
||||
}
|
||||
}
|
||||
@@ -24,8 +28,4 @@ public class MoveIdleState : MoveBaseState
|
||||
public override void FixedUpdateState(MoveStateManager mSM){
|
||||
mSM.DirectionalMovement();
|
||||
}
|
||||
|
||||
public override void OnCollisionEnter(MoveStateManager mSM){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,15 @@ using UnityEngine;
|
||||
|
||||
public class MoveJogState : MoveBaseState
|
||||
{
|
||||
public override void EnterState(MoveStateManager mSM){
|
||||
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
|
||||
Debug.Log("Jog State");
|
||||
//Debug.Log(mSM.calculatedCurVel);
|
||||
}
|
||||
|
||||
|
||||
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(MoveStateManager mSM){
|
||||
|
||||
//move to run state if speed increases
|
||||
@@ -21,7 +25,7 @@ public class MoveJogState : MoveBaseState
|
||||
}
|
||||
|
||||
//move to slide if Q or JoystickButton1
|
||||
if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && mSM.aSM.currentState != mSM.aSM.FallingState){
|
||||
if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && (mSM.aSM.currentState != mSM.aSM.FallingState && mSM.aSM.currentState != mSM.aSM.WallRunState && mSM.aSM.currentState != mSM.aSM.WallIdleState && mSM.aSM.currentState != mSM.aSM.GrappleGroundedState)){
|
||||
mSM.SwitchState(mSM.SlideState);
|
||||
}
|
||||
}
|
||||
@@ -29,8 +33,4 @@ public class MoveJogState : MoveBaseState
|
||||
public override void FixedUpdateState(MoveStateManager mSM){
|
||||
mSM.DirectionalMovement();
|
||||
}
|
||||
|
||||
public override void OnCollisionEnter(MoveStateManager mSM){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,15 @@ using UnityEngine;
|
||||
|
||||
public class MoveRunState : MoveBaseState
|
||||
{
|
||||
public override void EnterState(MoveStateManager mSM){
|
||||
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
|
||||
Debug.Log("Run State");
|
||||
//Debug.Log(mSM.calculatedCurVel);
|
||||
}
|
||||
|
||||
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(MoveStateManager mSM){
|
||||
|
||||
//move to Jog if speed decreases
|
||||
@@ -17,7 +21,7 @@ public class MoveRunState : MoveBaseState
|
||||
}
|
||||
|
||||
//move to slide if Q or JoystickButton1
|
||||
if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && mSM.aSM.currentState != mSM.aSM.FallingState){
|
||||
if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && (mSM.aSM.currentState != mSM.aSM.FallingState && mSM.aSM.currentState != mSM.aSM.WallRunState && mSM.aSM.currentState != mSM.aSM.WallIdleState && mSM.aSM.currentState != mSM.aSM.GrappleGroundedState)){
|
||||
mSM.SwitchState(mSM.SlideState);
|
||||
}
|
||||
}
|
||||
@@ -25,8 +29,4 @@ public class MoveRunState : MoveBaseState
|
||||
public override void FixedUpdateState(MoveStateManager mSM){
|
||||
mSM.DirectionalMovement();
|
||||
}
|
||||
|
||||
public override void OnCollisionEnter(MoveStateManager mSM){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,15 @@ using UnityEngine;
|
||||
|
||||
public class MoveWalkState : MoveBaseState
|
||||
{
|
||||
public override void EnterState(MoveStateManager mSM){
|
||||
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
|
||||
Debug.Log("Walk State");
|
||||
//Debug.Log(mSM.calculatedCurVel);
|
||||
}
|
||||
|
||||
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(MoveStateManager mSM){
|
||||
|
||||
//move to Jog if speed increases
|
||||
@@ -21,7 +25,7 @@ public class MoveWalkState : MoveBaseState
|
||||
}
|
||||
|
||||
//move to slide if Q or JoystickButton1
|
||||
if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && mSM.aSM.currentState != mSM.aSM.FallingState){
|
||||
if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && (mSM.aSM.currentState != mSM.aSM.FallingState && mSM.aSM.currentState != mSM.aSM.WallRunState && mSM.aSM.currentState != mSM.aSM.WallIdleState && mSM.aSM.currentState != mSM.aSM.GrappleGroundedState)){
|
||||
mSM.SwitchState(mSM.SlideState);
|
||||
}
|
||||
}
|
||||
@@ -29,8 +33,4 @@ public class MoveWalkState : MoveBaseState
|
||||
public override void FixedUpdateState(MoveStateManager mSM){
|
||||
mSM.DirectionalMovement();
|
||||
}
|
||||
|
||||
public override void OnCollisionEnter(MoveStateManager mSM){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8da7e24d55219204b86f9c99f23201c6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class NitroCooldownState : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 31aa143bf2a2d9c4ebccb1884b06e080
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class NitroIncapacitatedState : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a331aa9af6c346f43b8123be4e308693
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class NitroNitroingState : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cfb069621f651c743b64a3604ba25e8b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class NitroNoneState : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b274f44e4b258004587d2afe1c748474
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class NitroBaseState
|
||||
{
|
||||
public abstract void EnterState(NitroStateManager nSM, NitroBaseState previousState);
|
||||
public abstract void ExitState(NitroStateManager nSM, NitroBaseState nextState);
|
||||
public abstract void UpdateState(NitroStateManager nSM);
|
||||
public abstract void FixedUpdateState(NitroStateManager nSM);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7142e15316cd1694983f38a584c89346
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,28 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class NitroStateManager : MonoBehaviour
|
||||
{
|
||||
////Player States
|
||||
public NitroBaseState currentState;
|
||||
public NitroBaseState previousState;
|
||||
////
|
||||
|
||||
////Objects Sections
|
||||
GameObject parentObj; // Parent object
|
||||
public Camera cam; // Camera object
|
||||
////
|
||||
|
||||
////Components Section
|
||||
public CharacterController moveController; // Character Controller
|
||||
Rigidbody rB; // Players Rigidbody
|
||||
CapsuleCollider capCol; // Players Capsule Collider
|
||||
Animator animator; // Animation Controller
|
||||
////
|
||||
|
||||
////Scripts Section
|
||||
public PlayerStats pStats; // Player Stats
|
||||
public MoveStateManager mSM;
|
||||
////
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5f89839a9c7d0204ea00e910d9c5c5ee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b2292a829a1cb2c43b4e3889d4cfe7a6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class OffenseAirKickState : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e963653fb34d3184fba3fb7e4417ed75
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class OffenseAirPunchState : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f00bc672381c3a44b010d905fabe9a0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class OffenseKickState : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0447909f4233a324db4c49496dcc6bb8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class OffensePunchState : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 994ebfe06000a58488b76579ebf2c4dc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 703ef5745e09b544da4dace0f35c1ce5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class OffenseCooldownState : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d68d73793d961c640a7028eeeddded66
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class OffenseIncapacitatedState : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a55bc30803d5e034ca1a922fc86eff22
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class OffenseNoneState : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 49f93bffb8401e14dbd4b9ebf76442aa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class OffenseBaseState
|
||||
{
|
||||
public abstract void EnterState(OffenseStateManager oSM, OffenseBaseState previousState);
|
||||
public abstract void ExitState(OffenseStateManager oSM, OffenseBaseState nextState);
|
||||
public abstract void UpdateState(OffenseStateManager oSM);
|
||||
public abstract void FixedUpdateState(OffenseStateManager oSM);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 865c3dd440a18de45b59955da056df65
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,28 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class OffenseStateManager : MonoBehaviour
|
||||
{
|
||||
////Player States
|
||||
public OffenseBaseState currentState;
|
||||
public OffenseBaseState previousState;
|
||||
////
|
||||
|
||||
////Objects Sections
|
||||
GameObject parentObj; // Parent object
|
||||
public Camera cam; // Camera object
|
||||
////
|
||||
|
||||
////Components Section
|
||||
public CharacterController moveController; // Character Controller
|
||||
Rigidbody rB; // Players Rigidbody
|
||||
CapsuleCollider capCol; // Players Capsule Collider
|
||||
Animator animator; // Animation Controller
|
||||
////
|
||||
|
||||
////Scripts Section
|
||||
public PlayerStats pStats; // Player Stats
|
||||
public MoveStateManager mSM;
|
||||
////
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc5a1a9c85c29a744aa6ca7f1a8dbc60
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -17,8 +17,7 @@ public class GrapplingHook : NetworkBehaviour
|
||||
private CharacterController movementController;
|
||||
private PlayerMovement playerMovement;
|
||||
private PlayerStats pStats;
|
||||
[SerializeField] private float ropeLength;
|
||||
private float climbRate = 5;
|
||||
private float ropeLength;
|
||||
private Vector3 swingDirection;
|
||||
float inclinationAngle;
|
||||
float theta = -1;
|
||||
@@ -88,7 +87,7 @@ public class GrapplingHook : NetworkBehaviour
|
||||
release = false;
|
||||
lerpRelease = Vector3.zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
else //Else we are grappling
|
||||
{
|
||||
isGrappled = false; //toggle grappling state to release
|
||||
@@ -105,27 +104,6 @@ public class GrapplingHook : NetworkBehaviour
|
||||
{
|
||||
Debug.DrawRay(gameObject.transform.position, (hookPoint.transform.position - gameObject.transform.position)); //Visual of line
|
||||
|
||||
//Extend Hook
|
||||
if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.JoystickButton4))
|
||||
{
|
||||
ropeLength += climbRate * Time.deltaTime;
|
||||
if (ropeLength > maxGrappleDistance)
|
||||
{
|
||||
ropeLength = maxGrappleDistance;
|
||||
}
|
||||
//Debug.Log(ropeLength.ToString());
|
||||
}
|
||||
|
||||
//Retract Hook
|
||||
if (Input.GetKey(KeyCode.RightShift) || Input.GetKey(KeyCode.JoystickButton5))
|
||||
{
|
||||
ropeLength -= climbRate * Time.deltaTime;
|
||||
if (ropeLength < 8)
|
||||
{
|
||||
ropeLength = 8;
|
||||
}
|
||||
//Debug.Log(ropeLength.ToString());
|
||||
}
|
||||
//Debug.Log(Vector3.Distance(gameObject.transform.position, hookPoint.transform.position));
|
||||
//Calculate tether force direction based on hookpoint
|
||||
if (Vector3.Distance(gameObject.transform.position, hookPoint.transform.position) >= ropeLength )
|
||||
@@ -162,8 +140,7 @@ public class GrapplingHook : NetworkBehaviour
|
||||
|
||||
if(release){
|
||||
lerpRelease = Vector3.Lerp(lerpRelease, tempRelease, 10f * Time.deltaTime);
|
||||
tempRelease *= .99f;
|
||||
Debug.Log(lerpRelease);
|
||||
tempRelease *= .95f;
|
||||
movementController.Move(lerpRelease);
|
||||
}
|
||||
|
||||
@@ -315,11 +292,12 @@ public class GrapplingHook : NetworkBehaviour
|
||||
|
||||
Vector3 releaseSwingForceDirection = momDirection * ((swingMom) + 10);
|
||||
|
||||
releaseSwingForceDirection = new Vector3(releaseSwingForceDirection.x,0,releaseSwingForceDirection.z);
|
||||
releaseSwingForceDirection = new Vector3(releaseSwingForceDirection.x, 0, releaseSwingForceDirection.z);
|
||||
|
||||
if(swingMom < 5){
|
||||
return Vector3.zero;
|
||||
}
|
||||
|
||||
return releaseSwingForceDirection * Time.deltaTime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,16 +10,12 @@ public class WallRun : NetworkBehaviour
|
||||
public float wallMaxDistance = 3f;
|
||||
public float wallSpeedMultiplier = 1.2f;
|
||||
public float minimumHeight = .1f;
|
||||
public float maxAngleRoll = 20;
|
||||
[Range(0.0f, 1.0f)]
|
||||
public float normalizedAngleThreshold = 0.1f;
|
||||
|
||||
public float jumpDuration = .02f;
|
||||
public float wallBouncing = 3;
|
||||
public float cameraTransitionDuration = 1;
|
||||
|
||||
public float wallGravityDownForce = 2.8f;
|
||||
|
||||
[Space]
|
||||
PlayerMovement playerMovementController;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user