slide no longer rotates player

this means that currently the model doesn't rotate but that will be
rectified once we have the animations
This commit is contained in:
Melbyj1125 2022-02-23 00:00:43 -06:00
parent 5b18d2845c
commit 65a7008d24
18 changed files with 134 additions and 105 deletions

View File

@ -478,7 +478,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 5759777694531189237}
m_RootOrder: 1
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!20 &916243637571042078
Camera:
@ -693,7 +693,7 @@ Transform:
- {fileID: 7651374233674023408}
- {fileID: 6107527997929964892}
m_Father: {fileID: 2088235644774667867}
m_RootOrder: 1
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1521707349228591301
GameObject:
@ -757,7 +757,7 @@ Transform:
m_Children:
- {fileID: 3767772909335075234}
m_Father: {fileID: 2088235644774667867}
m_RootOrder: 0
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &4452213775082161952
MeshFilter:
@ -946,11 +946,12 @@ Transform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 30, y: 30, z: 30}
m_Children:
- {fileID: 3454051987037357494}
- {fileID: 3389602815704512536}
- {fileID: 5812657890528605903}
- {fileID: 8777733353107640407}
m_Father: {fileID: 5759777694531189237}
m_RootOrder: 2
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!95 &5339804152290053153
Animator:
@ -1192,7 +1193,6 @@ MonoBehaviour:
vel: {x: 0, y: 0, z: 0}
driftVel: {x: 0, y: 0, z: 0}
calculatedCurVel: 0
slideUp: {x: 0, y: 0, z: 0}
minAngle: -18
maxAngle: 30
sensitivity: 200
@ -1929,7 +1929,7 @@ Transform:
- {fileID: 792397752550538600}
- {fileID: 9070562083410256822}
m_Father: {fileID: 2088235644774667867}
m_RootOrder: 2
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &3194975341220055724
GameObject:
@ -2262,11 +2262,11 @@ Transform:
m_GameObject: {fileID: 3454051987037357495}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalScale: {x: 0.033333335, y: 0.033333335, z: 0.033333335}
m_Children:
- {fileID: 3454051987620051615}
- {fileID: 3454051986391715721}
m_Father: {fileID: 5759777694531189237}
m_Father: {fileID: 2088235644774667867}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &3454051987037357493
@ -4141,7 +4141,6 @@ Transform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 3454051987037357494}
- {fileID: 5827288694444457909}
- {fileID: 2088235644774667867}
m_Father: {fileID: 0}

View File

@ -1395,7 +1395,6 @@ Transform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 5975360321733016165}
- {fileID: 3304884871725760614}
- {fileID: 7059700519020685704}
m_Father: {fileID: 0}
@ -3453,11 +3452,11 @@ Transform:
m_GameObject: {fileID: 5975360321733016164}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalScale: {x: 0.033333335, y: 0.033333335, z: 0.033333335}
m_Children:
- {fileID: 5975360322223408460}
- {fileID: 5975360321271394394}
m_Father: {fileID: 3669633515805984294}
m_Father: {fileID: 7059700519020685704}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &5975360321733016166
@ -3805,7 +3804,7 @@ Transform:
- {fileID: 8646021746884051643}
- {fileID: 63863340556852325}
m_Father: {fileID: 7059700519020685704}
m_RootOrder: 2
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &6322357764579638395
GameObject:
@ -4199,7 +4198,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 7059700519020685704}
m_RootOrder: 3
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!136 &5804161043832888973
CapsuleCollider:
@ -4575,7 +4574,7 @@ Transform:
- {fileID: 1669950514738216483}
- {fileID: 3008883029677079183}
m_Father: {fileID: 7059700519020685704}
m_RootOrder: 1
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &7688428083034862386
GameObject:
@ -4616,12 +4615,13 @@ Transform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 30, y: 30, z: 30}
m_Children:
- {fileID: 5975360321733016165}
- {fileID: 5911456903690389451}
- {fileID: 3290243446330099996}
- {fileID: 347685973298016132}
- {fileID: 5981285733375990595}
m_Father: {fileID: 3669633515805984294}
m_RootOrder: 2
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!95 &3970262697637032946
Animator:
@ -4846,7 +4846,6 @@ MonoBehaviour:
vel: {x: 0, y: 0, z: 0}
driftVel: {x: 0, y: 0, z: 0}
calculatedCurVel: 0
slideUp: {x: 0, y: 0, z: 0}
minAngle: -18
maxAngle: 30
sensitivity: 200
@ -4938,7 +4937,7 @@ Transform:
m_Children:
- {fileID: 5281084129260463729}
m_Father: {fileID: 7059700519020685704}
m_RootOrder: 0
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &4668701882978121971
MeshFilter:
@ -5151,7 +5150,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 3669633515805984294}
m_RootOrder: 1
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!20 &8193413098731078861
Camera:

View File

@ -3040,6 +3040,18 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 1707207228499037409, guid: 0ea305f96ab853340bb9f0ed320dac08, type: 3}
propertyPath: m_Layer
value: 3
objectReference: {fileID: 0}
- target: {fileID: 1707207228499037465, guid: 0ea305f96ab853340bb9f0ed320dac08, type: 3}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3454051987037357495, guid: 0ea305f96ab853340bb9f0ed320dac08, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5759777694531189237, guid: 0ea305f96ab853340bb9f0ed320dac08, type: 3}
propertyPath: m_RootOrder
value: 10

View File

@ -15,12 +15,12 @@ public class dAerialFallingState : dAerialBaseState
public override void UpdateState(dAerialStateManager aSM){
//if Grav Vel > 0 then jumping
if(aSM.pStats.GravVel > 0 && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
if(aSM.pStats.GravVel > 0 && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.CrouchState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
aSM.SwitchState(aSM.JumpingState);
}
//if jump has been pressed and has glider and is in a state that allows it glide
else if(Input.GetButton("Jump") && aSM.pStats.HasGlider && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
else if(Input.GetButton("Jump") && aSM.pStats.HasGlider && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.CrouchState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
aSM.SwitchState(aSM.GlidingState);
}
@ -30,12 +30,12 @@ public class dAerialFallingState : dAerialBaseState
}
//if is wallrunning ands is in a state that allows it wallrun
else if(aSM.isWallRunning && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
else if(aSM.isWallRunning && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.CrouchState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
aSM.SwitchState(aSM.WallRunState);
}
//if grapple is possible and in state that allows it grapple air
else if(aSM.CheckGrapple() && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
else if(aSM.CheckGrapple() && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.CrouchState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
aSM.SwitchState(aSM.GrappleAirState);
}
}

View File

@ -17,16 +17,16 @@ public class dAerialGroundedState : dAerialBaseState
public override void UpdateState(dAerialStateManager aSM){
//if grav vel < 0 then falling
if(aSM.pStats.GravVel < 0 || (aSM.pStats.GravVel > 0 && (aSM.mSM.currentState == aSM.mSM.SlideState || aSM.mSM.currentState == aSM.mSM.RagdollState || aSM.mSM.currentState == aSM.mSM.RecoveringState))){
if(aSM.pStats.GravVel < 0 || (aSM.pStats.GravVel > 0 && (aSM.mSM.currentState == aSM.mSM.SlideState || aSM.mSM.currentState == aSM.mSM.CrouchState || aSM.mSM.currentState == aSM.mSM.RagdollState || aSM.mSM.currentState == aSM.mSM.RecoveringState))){
aSM.SwitchState(aSM.FallingState);
}
//if grav vel > 0 then jumping
else if(aSM.pStats.GravVel > 0 && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
else if(aSM.pStats.GravVel > 0 && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.CrouchState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
aSM.SwitchState(aSM.JumpingState);
}
//can grapple and in state that allows grapple
else if(aSM.CheckGrapple() && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
else if(aSM.CheckGrapple() && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.CrouchState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
aSM.SwitchState(aSM.GrappleGroundedState);
}
}

View File

@ -269,7 +269,7 @@ public class dAerialStateManager : NetworkBehaviour
//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)
if (Input.GetAxis("Jump") != 0 && !jumpHeld && curJumpNum < pStats.JumpNum && (mSM.currentState != mSM.SlideState && mSM.currentState != mSM.CrouchState && mSM.currentState != mSM.RagdollState && mSM.currentState != mSM.RecoveringState))
{
if(currentState == WallRunState){
AddImpact((GetWallJumpDirection()), pStats.JumpPow * 8.5f);

View File

@ -24,7 +24,7 @@ public class dMoveRagdollState : dMoveBaseState
public override void ExitState(dMoveStateManager mSM, dMoveBaseState nextState){
mSM.pStats.GravVel = 50; // resets gravVel
mSM.pStats.GravVel = 60; // resets gravVel
mSM.capCol.enabled = false; // disable capsule collider
mSM.moveController.enabled = true; // enable move controller
mSM.rB.isKinematic = true; // enable kinematic

View File

@ -7,14 +7,17 @@ public class dMoveCrouchState : dMoveBaseState
//Slide Variables
RaycastHit slideRay; // slide raycast
int layerMask;
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;
mSM.moveController.Move(new Vector3(0,-mSM.moveController.height * .5f,0));
layerMask = 1 << 3;
layerMask = ~layerMask;
}
}
@ -30,30 +33,34 @@ public class dMoveCrouchState : dMoveBaseState
}
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)){
if ((Physics.Raycast(mSM.gameObject.transform.position + new Vector3(0,1f,0), Vector3.up, out slideRay, 2f, layerMask) == false)){
mSM.SwitchState(mSM.IdleState);
}
else{
Debug.Log("Object above you");
Debug.Log(slideRay.collider.name);
}
}
//Debug.DrawRay(mSM.gameObject.transform.position + new Vector3(0,1f,0), Vector3.up * 2f, Color.red);
/*
//If falling stop sliding and go to wasd states
if(mSM.aSM.currentState == mSM.aSM.FallingState){
ExitCrouchState(mSM);
mSM.SwitchState(mSM.IdleState);
}
*/
}
public override void FixedUpdateState(dMoveStateManager mSM){
mSM.transform.Rotate(Vector3.up * -mSM.sensitivity * Time.deltaTime * Input.GetAxis("Mouse X"));
mSM.SlideMovement();
}
}

View File

@ -7,15 +7,18 @@ public class dMoveSlideState : dMoveBaseState
//Slide Variables
float originalTraction; // Traction before slide started
RaycastHit slideRay; // slide raycast
int layerMask;
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;
mSM.moveController.Move(new Vector3(0,-0.1f,0));
layerMask = 1 << 3;
layerMask = ~layerMask;
}
public override void ExitState(dMoveStateManager mSM, dMoveBaseState nextState){
@ -41,19 +44,12 @@ public class dMoveSlideState : dMoveBaseState
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 player isn't pressing either Q or the joystick button they stop sliding 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)){
if ((Physics.Raycast(mSM.gameObject.transform.position + new Vector3(0,1f,0), Vector3.up, out slideRay, 2f, layerMask) == false)){
//Determine which state to go into based on player speed
if(mSM.calculatedCurVel < mSM.walkLimit){
@ -67,30 +63,36 @@ public class dMoveSlideState : dMoveBaseState
}
}
else{
Debug.Log("Object above you");
Debug.Log(slideRay.collider.name);
}
}
//Debug.DrawRay(mSM.gameObject.transform.position + new Vector3(0,1f,0), Vector3.up * 2f, Color.red);
/*
//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);
}
}
*/
}
public override void FixedUpdateState(dMoveStateManager mSM){
//counter rotates player so they don't rotate when camera is turned
mSM.transform.Rotate(Vector3.up * -mSM.sensitivity * Time.deltaTime * Input.GetAxis("Mouse X"));
//actual slide movement
mSM.SlideMovement();
}

View File

@ -60,9 +60,6 @@ public class dMoveStateManager : NetworkBehaviour
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)]
@ -104,7 +101,6 @@ public class dMoveStateManager : NetworkBehaviour
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; }
@ -220,6 +216,11 @@ public class dMoveStateManager : NetworkBehaviour
Vector3 moveXZ = new Vector3(vel.x, 0, vel.z);
driftVel = Vector3.Lerp(driftVel, moveXZ, pStats.Traction * Time.deltaTime);
//need to have move controller involved for correct movement
if(currentState == CrouchState){
driftVel = Vector3.zero;
}
//Actually move he player
moveController.Move(driftVel);
}

View File

@ -15,12 +15,12 @@ public class AerialFallingState : AerialBaseState
public override void UpdateState(AerialStateManager aSM){
//if Grav Vel > 0 then jumping
if(aSM.pStats.GravVel > 0 && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
if(aSM.pStats.GravVel > 0 && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.CrouchState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
aSM.SwitchState(aSM.JumpingState);
}
//if jump has been pressed and has glider and is in a state that allows it glide
else if(Input.GetButton("Jump") && aSM.pStats.HasGlider && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
else if(Input.GetButton("Jump") && aSM.pStats.HasGlider && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.CrouchState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
aSM.SwitchState(aSM.GlidingState);
}
@ -30,12 +30,12 @@ public class AerialFallingState : AerialBaseState
}
//if is wallrunning ands is in a state that allows it wallrun
else if(aSM.isWallRunning && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
else if(aSM.isWallRunning && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.CrouchState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
aSM.SwitchState(aSM.WallRunState);
}
//if grapple is possible and in state that allows it grapple air
else if(aSM.CheckGrapple() && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
else if(aSM.CheckGrapple() && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.CrouchState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
aSM.SwitchState(aSM.GrappleAirState);
}
}

View File

@ -17,16 +17,16 @@ public class AerialGroundedState : AerialBaseState
public override void UpdateState(AerialStateManager aSM){
//if grav vel < 0 then falling
if(aSM.pStats.GravVel < 0 || (aSM.pStats.GravVel > 0 && (aSM.mSM.currentState == aSM.mSM.SlideState || aSM.mSM.currentState == aSM.mSM.RagdollState || aSM.mSM.currentState == aSM.mSM.RecoveringState))){
if(aSM.pStats.GravVel < 0 || (aSM.pStats.GravVel > 0 && (aSM.mSM.currentState == aSM.mSM.SlideState || aSM.mSM.currentState == aSM.mSM.CrouchState || aSM.mSM.currentState == aSM.mSM.RagdollState || aSM.mSM.currentState == aSM.mSM.RecoveringState))){
aSM.SwitchState(aSM.FallingState);
}
//if grav vel > 0 then jumping
else if(aSM.pStats.GravVel > 0 && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
else if(aSM.pStats.GravVel > 0 && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.CrouchState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
aSM.SwitchState(aSM.JumpingState);
}
//can grapple and in state that allows grapple
else if(aSM.CheckGrapple() && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
else if(aSM.CheckGrapple() && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.CrouchState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
aSM.SwitchState(aSM.GrappleGroundedState);
}
}

View File

@ -271,7 +271,7 @@ public class AerialStateManager : NetworkBehaviour
//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)
if (Input.GetAxis("Jump") != 0 && !jumpHeld && curJumpNum < pStats.JumpNum && (mSM.currentState != mSM.SlideState && mSM.currentState != mSM.CrouchState && mSM.currentState != mSM.RagdollState && mSM.currentState != mSM.RecoveringState))
{
if(currentState == WallRunState){
AddImpact((GetWallJumpDirection()), pStats.JumpPow * 8.5f);

View File

@ -24,7 +24,7 @@ public class MoveRagdollState : MoveBaseState
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
mSM.pStats.GravVel = 50; // resets gravVel
mSM.pStats.GravVel = 60; // resets gravVel
mSM.capCol.enabled = false; // disable capsule collider
mSM.moveController.enabled = true; // enable move controller
mSM.rB.isKinematic = true; // enable kinematic

View File

@ -60,9 +60,6 @@ public class MoveStateManager : NetworkBehaviour
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)]
@ -103,8 +100,6 @@ public class MoveStateManager : NetworkBehaviour
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; }
@ -220,6 +215,11 @@ public class MoveStateManager : NetworkBehaviour
Vector3 moveXZ = new Vector3(vel.x, 0, vel.z);
driftVel = Vector3.Lerp(driftVel, moveXZ, pStats.Traction * Time.deltaTime);
//Need to have movecontroller involved for correct movement
if(currentState == CrouchState){
driftVel = Vector3.zero;
}
//Actually move he player
moveController.Move(driftVel);
}

View File

@ -7,14 +7,17 @@ public class MoveCrouchState : MoveBaseState
//Slide Variables
RaycastHit slideRay; // slide raycast
int layerMask;
public override void EnterState(MoveStateManager mSM, MoveBaseState 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;
mSM.moveController.Move(new Vector3(0,-mSM.moveController.height * .5f,0));
layerMask = 1 << 3;
layerMask = ~layerMask;
}
}
@ -30,30 +33,34 @@ public class MoveCrouchState : MoveBaseState
}
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)){
if ((Physics.Raycast(mSM.gameObject.transform.position + new Vector3(0,1f,0), Vector3.up, out slideRay, 2f, layerMask) == false)){
mSM.SwitchState(mSM.IdleState);
}
else{
Debug.Log("Object above you");
Debug.Log(slideRay.collider.name);
}
}
//Debug.DrawRay(mSM.gameObject.transform.position + new Vector3(0,1f,0), Vector3.up * 2f, Color.red);
/*
//If falling stop sliding and go to wasd states
if(mSM.aSM.currentState == mSM.aSM.FallingState){
ExitCrouchState(mSM);
mSM.SwitchState(mSM.IdleState);
}
*/
}
public override void FixedUpdateState(MoveStateManager mSM){
mSM.transform.Rotate(Vector3.up * -mSM.sensitivity * Time.deltaTime * Input.GetAxis("Mouse X"));
mSM.SlideMovement();
}
}

View File

@ -7,15 +7,18 @@ public class MoveSlideState : MoveBaseState
//Slide Variables
float originalTraction; // Traction before slide started
RaycastHit slideRay; // slide raycast
int layerMask;
public override void EnterState(MoveStateManager mSM, MoveBaseState 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;
mSM.moveController.Move(new Vector3(0,-0.1f,0));
layerMask = 1 << 3;
layerMask = ~layerMask;
}
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
@ -41,19 +44,12 @@ public class MoveSlideState : MoveBaseState
mSM.SwitchState(mSM.CrouchState);
}
}
public override void FixedUpdateState(MoveStateManager 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 player isn't pressing either Q or the joystick button they stop sliding 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)){
if ((Physics.Raycast(mSM.gameObject.transform.position + new Vector3(0,1f,0), Vector3.up, out slideRay, 2f, layerMask) == false)){
//Determine which state to go into based on player speed
if(mSM.calculatedCurVel < mSM.walkLimit){
@ -67,30 +63,36 @@ public class MoveSlideState : MoveBaseState
}
}
else{
Debug.Log("Object above you");
Debug.Log(slideRay.collider.name);
}
}
//Debug.DrawRay(mSM.gameObject.transform.position + new Vector3(0,1f,0), Vector3.up * 2f, Color.red);
/*
//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);
}
}
*/
}
public override void FixedUpdateState(MoveStateManager mSM){
//counter rotates player so they don't rotate when camera is turned
mSM.transform.Rotate(Vector3.up * -mSM.sensitivity * Time.deltaTime * Input.GetAxis("Mouse X"));
//actual slide movement
mSM.SlideMovement();
}

View File

@ -9,29 +9,29 @@ EditorUserSettings:
value: 22424703114646680e0b0227036c6f1f05033f2b212d68252320092a
flags: 0
RecentlyUsedScenePath-1:
value: 22424703114646680e0b0227036c7b151b180b6501273035202c1327d1e33136e7a923e7ee2e26
flags: 0
RecentlyUsedScenePath-2:
value: 22424703114646680e0b0227036c6b19021b1d192f2d2835633c133af6f9
flags: 0
RecentlyUsedScenePath-3:
RecentlyUsedScenePath-2:
value: 22424703114646680e0b0227036c7b151b180b65093e273e12190f3cf6ef2021f2e225a7f234362820
flags: 0
RecentlyUsedScenePath-4:
RecentlyUsedScenePath-3:
value: 22424703114646680e0b0227036c7b151b180b652b3a27292f260573f1e33136e7a923e7ee2e26
flags: 0
RecentlyUsedScenePath-5:
value: 22424703114646680e0b0227036c7b151b180b6501273035202c1327d1e33136e7a923e7ee2e26
flags: 0
RecentlyUsedScenePath-6:
RecentlyUsedScenePath-4:
value: 22424703114646680e0b0227036c7c021313113e3f66333e243d04
flags: 0
RecentlyUsedScenePath-7:
RecentlyUsedScenePath-5:
value: 22424703114646680e0b0227036c78111b125507233d28242c20137df7ee3d2cfb
flags: 0
RecentlyUsedScenePath-8:
RecentlyUsedScenePath-6:
value: 22424703114646680e0b0227036c6f02131b172b282d347e38271427fb
flags: 0
RecentlyUsedScenePath-7:
value: 22424703114646680e0b0227036c7b151b180b652b3a27292f260573f1e33136e7a923e7ee2e26
flags: 0
RecentlyUsedScenePath-8:
value: 22424703114646680e0b0227036c7b151b180b6501273035202c1327d1e33136e7a923e7ee2e26
flags: 0
RecentlyUsedScenePath-9:
value: 22424703114646680e0b0227036c7b151b180b652b3a27292f260573f1e33136e7a923e7ee2e26
flags: 0