Merge branch 'movementCleanup'

This commit is contained in:
Melbyj1125
2021-11-05 12:35:27 -05:00
36 changed files with 2174 additions and 371 deletions

View File

@@ -51,7 +51,7 @@ public class PlayerMovement : NetworkBehaviour
//Camera Variables
private LayerMask ignoreP;
private Vector3 camRotation;
private Camera cam;
public Camera cam;
[Range(-45, -15)]
public int minAngle = -30;
@@ -89,9 +89,6 @@ public class PlayerMovement : NetworkBehaviour
pStats = GetComponent<PlayerStats>();
parentObj = transform.parent.gameObject;
//camera transform
cam = parentObj.GetComponentInChildren<Camera>();
capCol.enabled = false;
//Wallrun
wallRun = gameObject.GetComponent<WallRun>();
@@ -104,7 +101,8 @@ public class PlayerMovement : NetworkBehaviour
// Don't do movement unless this is the local player controlling it
// Otherwise we let the server handle moving us
if (!IsLocalPlayer) { return; }
//if (!IsLocalPlayer) { return; }
// Don't lock the cursor multiple times if this isn't the local player
// Also don't want to lock the cursor for the king
@@ -117,12 +115,17 @@ public class PlayerMovement : NetworkBehaviour
{
// Don't do movement unless this is the local player controlling it
// Otherwise we let the server handle moving us
if (!IsLocalPlayer) { return; }
//if (!IsLocalPlayer) { return; }
//Controls for camera
Rotation();
if(cam.enabled){
Rotation();
}
else Debug.Log("Cam Disabled");
//Allow Movement when moveController is enabled
if(moveController.enabled == true){
//input controls for movement
@@ -149,20 +152,17 @@ public class PlayerMovement : NetworkBehaviour
//Debug.LogWarning("MoveController is either Disabled or wasn't retrieved correctly");
}
//TESTING RAGDOLL STUFF NEEDS SOME WORK
//Checks if player should respawn
//Respawn();
//TEMP FOR TESTING RAGDOLL
//Right Click to ragdoll the player
if (Input.GetMouseButton(1) && heldDown == false){
getHit(new Vector3(vel.x, 0, vel.z), 30);
heldDown = true;
}
if(!Input.GetMouseButton(1)){
heldDown = false;
}
//TEMP FOR TESTING
//Checks if player should respawn
Respawn();
@@ -175,6 +175,7 @@ public class PlayerMovement : NetworkBehaviour
{
//Check if player is grounded before each frame
GroundCheck();
//Keyboard inputs
//Checks if movement keys have been pressed and calculates correct vector
@@ -196,6 +197,7 @@ public class PlayerMovement : NetworkBehaviour
//Slide Function
Slide();
//Move Player
moveController.Move(driftVel);
}
@@ -232,9 +234,11 @@ public class PlayerMovement : NetworkBehaviour
//Applies impact in a direction with the given force
//Apply Impact for when force needs to be applied without ragdolling
public void AddImpact(Vector3 dir, float force)
{
//if (!IsLocalPlayer) { return; }
dir.Normalize();
if (dir.y < 0) dir.y = -dir.y; // reflect down force on the ground
impact += dir.normalized * force / mass;
@@ -308,11 +312,6 @@ public class PlayerMovement : NetworkBehaviour
cam.transform.localEulerAngles = camRotation;
}
/*
else{
cam.transform.localEulerAngles = cam.transform.localEulerAngles - rotOffset;
}
*/
}
@@ -360,7 +359,7 @@ public class PlayerMovement : NetworkBehaviour
}
//Checks if player is grounded
void GroundCheck()
{
// Make sure that the ground check distance while already in air is very small, to prevent suddenly snapping to ground
@@ -439,7 +438,7 @@ public class PlayerMovement : NetworkBehaviour
pStats.Traction = 0.01f;
}
pStats.Traction += .02f;
pStats.Traction += .004f;
}
else{
qDown = false;
@@ -460,24 +459,6 @@ public class PlayerMovement : NetworkBehaviour
}
}
//if button is not held down, and still slidding (if they let go but something was above them) check to see if something is still above them, if not
else if (Input.GetKey(KeyCode.Q) == false && isSliding==true){
//if nothing is above the object, stop slidding
if (Physics.Raycast(this.gameObject.transform.position, up, out ray, 5f) == false)
{
this.gameObject.transform.eulerAngles = new Vector3(this.transform.eulerAngles.x - 90, this.transform.eulerAngles.y, this.transform.eulerAngles.z);
isSliding = false;
moveController.height = 2.0f;
pStats.Traction = originalTraction;
}
else
{
Debug.Log("Object above you");
}
}
}
}