Cleaned up the expanded area and gave all obstacles more space between each other as well as fine tuning and fixing all noticeable issuses with all crouch based movements

This commit is contained in:
Gregory Campbell
2020-01-05 12:56:23 -05:00
parent d4fafd63d3
commit e6db8a979c
2 changed files with 44 additions and 32 deletions
+28 -16
View File
@@ -23,8 +23,10 @@ public class PlayerController : MonoBehaviour
private bool wallRunning = false;
private bool diving = false;
private bool sliding = false;
private int jump = 0;
private int wall = 0;
private int dive = 0;
private float maxSpeedStore;
private float maxSpeedCap = 100;
private float accelerationStore;
@@ -37,7 +39,8 @@ public class PlayerController : MonoBehaviour
private Vector3 velocity;
private Vector3 gravityVelocity;
float startTime = 0.0f;
float slideTime = 0.0f;
float wallRunTime = 0.0f;
float oneSec = 1.0f;
float halfSec = 0.5f;
float quarterSec = 0.25f;
@@ -84,7 +87,7 @@ public class PlayerController : MonoBehaviour
if (characterController.isGrounded)
{
diving = false;
wallRunning = false;
dive = 0;
jump = 0;
moveDirection.y = 0.0f;
@@ -113,13 +116,18 @@ public class PlayerController : MonoBehaviour
capsule.height /= 2;
transform.localScale = new Vector3(transform.localScale.x, transformHeight/2, transform.localScale.z);
if(Input.GetKeyDown(KeyCode.LeftControl) && characterController.velocity != new Vector3(0, 0, 0)
&& (Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0))
if(Input.GetKeyDown(KeyCode.LeftControl))
{
startTime = Time.time;
if((Input.GetAxis("Horizontal") == 0 && Input.GetAxis("Vertical") == 0))
{
sliding = false;
} else {
sliding = true;
slideTime = Time.time;
}
}
if(startTime + halfSec >= Time.time)
if(slideTime + halfSec >= Time.time && sliding == true)
{
if(maxSpeed < maxSpeedStore*2)
@@ -127,7 +135,7 @@ public class PlayerController : MonoBehaviour
maxSpeed += acceleration*2;
}
if(Input.GetButton("Jump") && startTime + quarterSec >= Time.time)
if(Input.GetButton("Jump") && slideTime + quarterSec >= Time.time)
{
maxSpeed += 5;
}
@@ -150,7 +158,7 @@ public class PlayerController : MonoBehaviour
}
} else {
startTime = Time.time;
slideTime = Time.time;
if(Input.GetKey(KeyCode.LeftControl))
{
@@ -168,6 +176,16 @@ public class PlayerController : MonoBehaviour
}
//Might want to change move direction value to make triggering this speed up effect easier/harder
if(diving && moveDirection.y > 0.75 && Input.GetKeyDown(KeyCode.LeftControl))
{
dive++;
if(dive == 1){
maxSpeed += 10;
}
}
}
if (Input.GetButtonDown("Jump") && jump <= 1)
@@ -196,10 +214,10 @@ public class PlayerController : MonoBehaviour
if(wall == 1)
{
startTime = Time.time;
wallRunTime = Time.time;
}
if(startTime + oneSec < Time.time)
if(wallRunTime + oneSec < Time.time)
{
moveDirection.y += Physics.gravity.y * (gravity/8) * Time.deltaTime;
@@ -242,12 +260,6 @@ public class PlayerController : MonoBehaviour
velocity.z = velocity.z * Mathf.Abs(moveDirection.y);
}
if(diving)
{
velocity.x *= 1.5f;
velocity.z *= 1.5f;
}
// Move the controller
characterController.Move(velocity * Time.deltaTime);