adjusted anything that refered to playerMovement

This commit is contained in:
Melbyj1125
2022-02-16 16:44:30 -06:00
parent f0936f4cee
commit e74a1c61c0
112 changed files with 60 additions and 67 deletions

View File

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

View File

@@ -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){
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ef1fdba284bf4db40903d97f11507813
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

@@ -0,0 +1,50 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MoveRagdollState : MoveBaseState
{
float ragTime;
Vector3 prevRot;
bool beginRagTimer = false;
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
ragTime = mSM.pStats.RecovTime;
prevRot = mSM.transform.localEulerAngles;
mSM.capCol.enabled = true;
mSM.moveController.enabled = false;
mSM.rB.isKinematic = false;
mSM.rB.detectCollisions = true;
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);
}
else{
ragTime -= Time.deltaTime;
}
}
public override void FixedUpdateState(MoveStateManager mSM){
//Has to be in Fixed Update because it has player movement
if(ragTime <= 0 && beginRagTimer){
ragTime = 0;
beginRagTimer = false;
mSM.SwitchState(mSM.RecoveringState);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b7164475ffa0df6409ecd43b0517e4b0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,24 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MoveRecoveringState : MoveBaseState
{
////// ADD SOMETHING THAT CHECKS ANIMATION FINISH BEFORE GO TO IDLE
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);
}
public override void FixedUpdateState(MoveStateManager mSM){
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dee57766c5fb3c34c8979d3e14d4e94e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public abstract class MoveBaseState
{
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);
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7faaa4b89293d9e4992142ab5c4fcc35
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,269 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MLAPI;
public class MoveStateManager : NetworkBehaviour
{
////Player States
public MoveBaseState currentState;
public MoveBaseState previousState;
//WASD States
public MoveIdleState IdleState = new MoveIdleState();
public MoveWalkState WalkState = new MoveWalkState();
public MoveJogState JogState = new MoveJogState();
public MoveRunState RunState = new MoveRunState();
//Slide States
public MoveSlideState SlideState = new MoveSlideState();
public MoveCrouchState CrouchState = new MoveCrouchState();
public MoveCrouchWalkState CrouchWalkState = new MoveCrouchWalkState();
//Incapitated States
public MoveRagdollState RagdollState = new MoveRagdollState();
public MoveRecoveringState RecoveringState = new MoveRecoveringState();
//Grapple States
public MoveGrappleAirState GrappleAirState = new MoveGrappleAirState();
////
////Objects Sections
private GameObject parentObj; // Parent object
public Camera cam; // Camera object
////
////Components Section
public CharacterController moveController; // Character Controller
public Rigidbody rB; // Players Rigidbody
public CapsuleCollider capCol; // Players Capsule Collider
private Animator animator; // Animation Controller
////
////Scripts Section
public PlayerStats pStats; // Player Stats
public AerialStateManager aSM;
////
////State Transition Variables
public float idleLimit = .3f;
public float walkLimit = 10.0f;
public float jogLimit = 20f;
public float runLimit = 30f;
////
////Player Variables Section
//Speed Variables
public Vector3 vel; // moveZ + moveX
private Vector3 moveZ; // Local Horizontal Vector
private Vector3 moveX; // Local Vertical Vector
public Vector3 driftVel; // Lerped Movement Vector
public float calculatedCurVel; // calculated current vel using driftVel
//Slide Variables
public Vector3 slideUp; // Slide upwards direction
//Camera Variables
private Vector3 camRotation; // cameras camera rotation vector
[Range(-45, -15)]
public int minAngle = -30; // minimum downwards cam angle
[Range(30, 80)]
public int maxAngle = 45; // Max upwards cam angle
[Range(50, 500)]
public int sensitivity = 200; // Camera sensitivity
//Ragdoll Variables
public Vector3 dirHit; // Direction hit
public float distToGround; // distance to ground
////
void Awake(){
////Initialize Player Components
moveController = GetComponent<CharacterController>(); // set Character Controller
rB = GetComponent<Rigidbody>(); //set Rigid Body
capCol = GetComponent<CapsuleCollider>(); // set Capsule Collider
capCol.enabled = true;
parentObj = transform.parent.gameObject; // set parent object
animator = GetComponent<Animator>(); // set animator
////
////Initialize Scripts
pStats = GetComponent<PlayerStats>(); // set PlayerStats
aSM = GetComponent<AerialStateManager>();
////
}
// Start is called before the first frame update
void Start()
{
//players starting state
currentState = IdleState;
previousState = IdleState;
currentState.EnterState(this, previousState);
//Slide Upwards Variable
slideUp = GetComponentInParent<Transform>().up; // get parents up direction
distToGround = GetComponent<Collider>().bounds.extents.y; // set players distance to ground
if (!IsLocalPlayer) { return; }
Cursor.lockState = CursorLockMode.Locked; // Lock cursor on start if you are the local player
}
// Update is called once per frame
void Update()
{
//if (!IsLocalPlayer) { return; }
//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);
}
void FixedUpdate(){
//if (!IsLocalPlayer) { return; }
//calls any logic in the fixed update state from current state
currentState.FixedUpdateState(this);
if(cam.enabled) Rotation();
else Debug.Log("Cam Disabled");
}
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, previousState);
}
////Broad Functions
//Player Speed Calculator
public float PlayerSpeed(){
//If nothing is pressed speed is 0
if ((Input.GetAxis("Vertical") == 0.0f && Input.GetAxis("Horizontal") == 0.0f))
{
pStats.CurVel = 0.0f;
return pStats.CurVel;
}
//If current speed is below min when pressed set to minimum speed
else if (pStats.CurVel < pStats.MinVel)
{
pStats.CurVel = pStats.MinVel;
return pStats.MinVel;
}
// while the speed is below max speed slowly increase it
else if ((pStats.CurVel >= pStats.MinVel) && (pStats.CurVel < pStats.MaxVel))
{
pStats.CurVel += pStats.Acc;
return pStats.CurVel;
}
//If the players speed is above or equal to max speed set speed to max
else if (pStats.CurVel >= pStats.MaxVel)
{
pStats.CurVel = pStats.MaxVel;
return pStats.CurVel;
}
//case if somehow they escape this check
else{
Debug.Log("Something has gone wrong with the PlayerSpeed()");
return -1;
}
}
//Wasd movement using player speed
public void DirectionalMovement(){
//Keyboard inputs
//Checks if movement keys have been pressed and calculates correct vector
moveX = transform.right * Input.GetAxis("Horizontal") * Time.deltaTime * PlayerSpeed();
moveZ = transform.forward * Input.GetAxis("Vertical") * Time.deltaTime * PlayerSpeed();
vel = moveX + moveZ;
Vector3 moveXZ = new Vector3(vel.x, 0, vel.z);
driftVel = Vector3.Lerp(driftVel, moveXZ, pStats.Traction * Time.deltaTime);
//Actually move he player
moveController.Move(driftVel);
}
//Slide movement
public void SlideMovement(){
moveX = Vector3.zero;
moveZ = Vector3.zero;
//Adds vectors based on movement keys and other conditions to check what the
//player vector should be under the circumstances
vel = moveX + moveZ;
Vector3 moveXZ = new Vector3(vel.x, 0, vel.z);
driftVel = Vector3.Lerp(driftVel, moveXZ, pStats.Traction * Time.deltaTime);
//Actually move he player
moveController.Move(driftVel);
}
//Camera and player rotation
private void Rotation(){
//If moveController is enabled allow Camera control
if(moveController.enabled){
//if input is received from Mouse X
if (Input.GetAxis("Mouse X") != 0){
transform.parent.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("Mouse X"));
}
//if input is received from right analog stick (horizontal)
else if(Input.GetAxis("HorizontalCam") != 0){
transform.parent.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("HorizontalCam"));
}
//if input is if input is received from Mouse Y
if (Input.GetAxis("Mouse Y") != 0)
{
camRotation.x -= Input.GetAxis("Mouse Y") * sensitivity * Time.deltaTime;
camRotation.x = Mathf.Clamp(camRotation.x, minAngle, maxAngle);
cam.transform.localEulerAngles = camRotation;
}
//if input is received from right analog stick (vertical)
else if (Input.GetAxis("VerticalTurn") != 0){
camRotation.x -= Input.GetAxis("VerticalTurn") * sensitivity * Time.deltaTime;
camRotation.x = Mathf.Clamp(camRotation.x, minAngle, maxAngle);
cam.transform.localEulerAngles = camRotation;
}
}
}
public void GetHit(Vector3 dir, float force){
//if (!IsLocalPlayer) { return; }
dir.Normalize();
dirHit = dir * force;
SwitchState(RagdollState);
}
public void CancelMomentum(){
pStats.CurVel = 0;
vel = Vector3.zero;
moveX = Vector3.zero;
moveZ = Vector3.zero;
driftVel = Vector3.zero;
}
void GoToGrapple(){
if(aSM.currentState == aSM.GrappleAirState && (currentState != SlideState && currentState != RagdollState && currentState != RecoveringState)){
SwitchState(GrappleAirState);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7adf74561e73e1c4e99ec7e3d6a08738
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

@@ -0,0 +1,57 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MoveCrouchState : MoveBaseState
{
//Slide Variables
RaycastHit slideRay; // slide raycast
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
if(previousState != mSM.SlideState){
//Initialize Important Stats On state enter
mSM.pStats.CurVel = 0;
mSM.gameObject.transform.eulerAngles = new Vector3(mSM.transform.localEulerAngles.x - 90, mSM.transform.localEulerAngles.y, mSM.transform.localEulerAngles.z);
mSM.moveController.height *= .5f;
}
}
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.moveController.height *= 2.0f;
}
}
public override void UpdateState(MoveStateManager mSM){
}
public override void FixedUpdateState(MoveStateManager mSM){
mSM.transform.Rotate(Vector3.forward * -mSM.sensitivity * Time.deltaTime * Input.GetAxis("Mouse X"));
///////ONCE WE HAVE IT SO SLIDE DOESNT ROTATE PLAYER MOVE THIS TO UPDATE
//If player isn't pressing either Q or the joystick button they stop crouching if nothing is above them
if((!Input.GetKey(KeyCode.JoystickButton1) && !Input.GetKey(KeyCode.Q))){
if ((Physics.Raycast(mSM.gameObject.transform.position, mSM.slideUp, out slideRay, 5f) == false)){
mSM.SwitchState(mSM.IdleState);
}
else{
Debug.Log("Object above you");
}
}
/*
//If falling stop sliding and go to wasd states
if(mSM.aSM.currentState == mSM.aSM.FallingState){
ExitCrouchState(mSM);
mSM.SwitchState(mSM.IdleState);
}
*/
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 88c903fd0284d184dade30af31081373
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,40 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MoveCrouchWalkState : MoveBaseState
{
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
}
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
}
public override void UpdateState(MoveStateManager mSM){
}
public override void FixedUpdateState(MoveStateManager mSM){
/*
if(mSM.aSM.currentState == mSM.aSM.FallingState){
//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);
}
}
*/
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 502d8c0b8175a794ab08d2798a29465c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,87 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MoveSlideState : MoveBaseState
{
//Slide Variables
float originalTraction; // Traction before slide started
RaycastHit slideRay; // slide raycast
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
//Initialize Important Stats On state enter
mSM.pStats.CurVel = 0;
originalTraction = mSM.pStats.Traction;
mSM.gameObject.transform.eulerAngles = new Vector3(mSM.transform.eulerAngles.x - 90, mSM.transform.eulerAngles.y, mSM.transform.eulerAngles.z);
mSM.moveController.height *= .5f;
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;
}
else{
mSM.pStats.Traction = originalTraction;
}
}
public override void UpdateState(MoveStateManager mSM){
//if player comes to a stop while sliding they crouch
if(mSM.calculatedCurVel < mSM.idleLimit){
mSM.SwitchState(mSM.CrouchState);
}
}
public override void FixedUpdateState(MoveStateManager mSM){
mSM.transform.Rotate(Vector3.forward * -mSM.sensitivity * Time.deltaTime * Input.GetAxis("Mouse X"));
mSM.pStats.Traction += .004f;
///////ONCE WE HAVE IT SO SLIDE DOESNT ROTATE PLAYER MOVE THIS TO UPDATE
if((!Input.GetKey(KeyCode.JoystickButton1) && !Input.GetKey(KeyCode.Q))){
if ((Physics.Raycast(mSM.gameObject.transform.position, mSM.slideUp, out slideRay, 5f) == false)){
//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);
}
}
else{
Debug.Log("Object above you");
}
}
/*
//If falling stop sliding and go to wasd states
if(mSM.aSM.currentState == mSM.aSM.FallingState){
//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);
}
}
*/
mSM.SlideMovement();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4338a9bf5309e75489870c3702150aa8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

@@ -0,0 +1,31 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MoveIdleState : MoveBaseState
{
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
}
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
}
public override void UpdateState(MoveStateManager mSM){
//Move to Walk State after speed increases
if(mSM.calculatedCurVel >= mSM.idleLimit){
mSM.SwitchState(mSM.WalkState);
}
//If Q or joystick button1 crouch state
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);
}
}
public override void FixedUpdateState(MoveStateManager mSM){
mSM.DirectionalMovement();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 125078d4aa4c6df499f04e79c5142b5f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,35 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MoveJogState : MoveBaseState
{
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
}
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
}
public override void UpdateState(MoveStateManager mSM){
//move to run state if speed increases
if(mSM.calculatedCurVel >= mSM.runLimit){
mSM.SwitchState(mSM.RunState);
}
//move to walk if speed decreases
else if(mSM.calculatedCurVel < mSM.walkLimit){
mSM.SwitchState(mSM.WalkState);
}
//move to slide if Q or JoystickButton1
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);
}
}
public override void FixedUpdateState(MoveStateManager mSM){
mSM.DirectionalMovement();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 51bfa6fd57184214195d51b209c92454
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,31 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MoveRunState : MoveBaseState
{
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
}
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
}
public override void UpdateState(MoveStateManager mSM){
//move to Jog if speed decreases
if(mSM.calculatedCurVel < mSM.runLimit){
mSM.SwitchState(mSM.JogState);
}
//move to slide if Q or JoystickButton1
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);
}
}
public override void FixedUpdateState(MoveStateManager mSM){
mSM.DirectionalMovement();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 022dbadfec93fcf489a6e2bab39d0553
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,35 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MoveWalkState : MoveBaseState
{
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
}
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
}
public override void UpdateState(MoveStateManager mSM){
//move to Jog if speed increases
if(mSM.calculatedCurVel >= mSM.jogLimit){
mSM.SwitchState(mSM.JogState);
}
//move to Idle if speed decreases
else if(mSM.calculatedCurVel < mSM.idleLimit){
mSM.SwitchState(mSM.IdleState);
}
//move to slide if Q or JoystickButton1
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);
}
}
public override void FixedUpdateState(MoveStateManager mSM){
mSM.DirectionalMovement();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 44721a52e3dd5634bbd29b627ef2886b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: