adjusted momentum loss

This commit is contained in:
Melbyj1125
2022-03-20 07:12:46 -05:00
parent 4d806060a7
commit ebf15ceb66
4 changed files with 212 additions and 212 deletions

View File

@@ -63,7 +63,7 @@ public class MoveStateManager : NetworkBehaviour
public Vector3 driftVel; // Lerped Movement Vector
public float calculatedCurVel; // calculated current vel using driftVel
public int layerMask; // LayerMask to exclude player
RaycastHit wallHitTop, wallHitBot; // Raycast for momentum loss on wall hit
RaycastHit wallHitTop, wallHitBot, wallExitTop, wallExitBot; // Raycast for momentum loss on wall hit
private Vector3 lastVel; // previous vel
private bool firstWallHit = false; // hit the wall for the first time
@@ -226,22 +226,22 @@ public class MoveStateManager : NetworkBehaviour
//Check if wall is in direction player is moving
if (((Physics.Raycast(gameObject.transform.position + new Vector3(0,.4f,0) + rayOffset, driftVel.normalized, out wallHitBot, .18f, layerMask) == true) || ((currentState != SlideState || currentState != CrouchState) && (Physics.Raycast(gameObject.transform.position + new Vector3(0,2.2f,0), driftVel.normalized, out wallHitTop, .18f, layerMask) == true))) && !firstWallHit){
if (((Physics.Raycast(gameObject.transform.position + new Vector3(0,.4f,0) + rayOffset, driftVel.normalized, out wallHitBot, .5f, layerMask) == true) || ((currentState != SlideState || currentState != CrouchState) && (Physics.Raycast(gameObject.transform.position + new Vector3(0,2.2f,0), driftVel.normalized, out wallHitTop, .5f, layerMask) == true))) && !firstWallHit){
CancelMomentum();
Debug.Log("Collide");
//Debug.Log(wallHitBot.collider.name);
firstWallHit = true;
}
if(((Physics.Raycast(gameObject.transform.position + new Vector3(0,.4f,0) + rayOffset, driftVel.normalized, out wallExitBot, .3f, layerMask) == false) && ((currentState == SlideState || currentState == CrouchState) || (Physics.Raycast(gameObject.transform.position + new Vector3(0,2.2f,0), driftVel.normalized, out wallExitTop, .3f, layerMask) == false))) && firstWallHit){
firstWallHit = false;
}
Debug.DrawRay(gameObject.transform.position + new Vector3(0,.4f,0) + (rayOffset/2), moveXZ.normalized * .2f, Color.red);
Debug.DrawRay(gameObject.transform.position + new Vector3(0,2.2f,0) + rayOffset, moveXZ.normalized * .2f, Color.red);
Debug.DrawRay(gameObject.transform.position + new Vector3(0,.4f,0) + rayOffset, driftVel.normalized * .5f, Color.red);
Debug.DrawRay(gameObject.transform.position + new Vector3(0,2.2f,0) + rayOffset, driftVel.normalized * .5f, Color.red);
if(driftVel != Vector3.zero){
playerModel.transform.rotation = Quaternion.LookRotation(driftVel.normalized);
}
//Actually move he player
moveController.Move(driftVel);