mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-21 18:04:27 -05:00
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:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user