Cleaned up code

Slide Works again
Ragdoll works again
Cam is stable
New Debugging prefab
This commit is contained in:
Melbyj1125
2021-11-03 14:06:19 -05:00
parent 76cd66fa0b
commit 7c72259708
36 changed files with 2193 additions and 346 deletions

View File

@@ -105,7 +105,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
@@ -118,12 +119,14 @@ 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();
//Allow Movement when moveController is enabled
if(moveController.enabled == true){
//input controls for movement
@@ -150,18 +153,17 @@ public class PlayerMovement : NetworkBehaviour
//Debug.LogWarning("MoveController is either Disabled or wasn't retrieved correctly");
}
//TESTING RAGDOLL STUFF NEEDS SOME WORK
//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();
@@ -174,6 +176,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
@@ -195,6 +198,7 @@ public class PlayerMovement : NetworkBehaviour
//Slide Function
Slide();
//Move Player
moveController.Move(driftVel);
}
@@ -231,9 +235,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;
@@ -301,11 +307,6 @@ public class PlayerMovement : NetworkBehaviour
cam.transform.localEulerAngles = camRotation;
}
/*
else{
cam.transform.localEulerAngles = cam.transform.localEulerAngles - rotOffset;
}
*/
}
@@ -353,7 +354,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
@@ -432,7 +433,7 @@ public class PlayerMovement : NetworkBehaviour
pStats.Traction = 0.01f;
}
pStats.Traction += .02f;
pStats.Traction += .004f;
}
else{
qDown = false;
@@ -453,24 +454,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");
}
}
}
}