created a debug prefab

This commit is contained in:
Melbyj1125
2022-02-18 13:56:10 -06:00
parent 820b11dd61
commit 167f7840a0
108 changed files with 9076 additions and 123 deletions

View File

@@ -0,0 +1,59 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class dMoveCrouchState : dMoveBaseState
{
//Slide Variables
RaycastHit slideRay; // slide raycast
public override void EnterState(dMoveStateManager mSM, dMoveBaseState previousState){
//if not coming from slide state then rotate player and adjust height
if(previousState != mSM.SlideState){
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(dMoveStateManager mSM, dMoveBaseState nextState){
//if next state isn't crouch walk revert rotation, speed, and height
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(dMoveStateManager mSM){
}
public override void FixedUpdateState(dMoveStateManager 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: 68982636ca83cdf4a951928206dd334f
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 dMoveCrouchWalkState : dMoveBaseState
{
public override void EnterState(dMoveStateManager mSM, dMoveBaseState previousState){
}
public override void ExitState(dMoveStateManager mSM, dMoveBaseState nextState){
}
public override void UpdateState(dMoveStateManager mSM){
}
public override void FixedUpdateState(dMoveStateManager 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: 1ace36bef6e24634d9c051e1530efd99
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,97 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class dMoveSlideState : dMoveBaseState
{
//Slide Variables
float originalTraction; // Traction before slide started
RaycastHit slideRay; // slide raycast
public override void EnterState(dMoveStateManager mSM, dMoveBaseState previousState){
//Rotate player and adjust height and adjust traction
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(dMoveStateManager mSM, dMoveBaseState nextState){
//if next state isn't crouch then revert player rotation, height, and traction
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;
}
//if state is crouch revert traction
else{
mSM.pStats.Traction = originalTraction;
}
}
public override void UpdateState(dMoveStateManager mSM){
//if player comes to a stop while sliding they crouch
if(mSM.calculatedCurVel < mSM.idleLimit){
mSM.SwitchState(mSM.CrouchState);
}
}
public override void FixedUpdateState(dMoveStateManager mSM){
//counter rotates player so they don't rotate when camera is turned
mSM.transform.Rotate(Vector3.forward * -mSM.sensitivity * Time.deltaTime * Input.GetAxis("Mouse X"));
//steadily increase traction
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);
}
}
*/
//actual slide movement
mSM.SlideMovement();
}
}

View File

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