From e6db8a979ce9dd14d12390377e6ddcbea78124fb Mon Sep 17 00:00:00 2001 From: Gregory Campbell Date: Sun, 5 Jan 2020 12:56:23 -0500 Subject: [PATCH] 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 --- Assets/Scenes/Test Scene.unity | 32 +++++++++++----------- Assets/Scripts/PlayerController.cs | 44 +++++++++++++++++++----------- 2 files changed, 44 insertions(+), 32 deletions(-) diff --git a/Assets/Scenes/Test Scene.unity b/Assets/Scenes/Test Scene.unity index 096ecad..9501240 100644 --- a/Assets/Scenes/Test Scene.unity +++ b/Assets/Scenes/Test Scene.unity @@ -180,7 +180,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 194035203} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 80, y: 6.5, z: 12} + m_LocalPosition: {x: 155, y: 6.5, z: 12} m_LocalScale: {x: 75, y: 20, z: 0.25} m_Children: [] m_Father: {fileID: 1013482115} @@ -273,7 +273,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 195913138} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 21, y: 2.5, z: -30} + m_LocalPosition: {x: 42, y: 2.5, z: -49.5} m_LocalScale: {x: 10, y: 5, z: 10} m_Children: [] m_Father: {fileID: 746704017} @@ -366,8 +366,8 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 203887784} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 120, y: -0.5, z: 6} - m_LocalScale: {x: 20, y: 0.5, z: 12} + m_LocalPosition: {x: 200, y: -0.5, z: 6} + m_LocalScale: {x: 50, y: 0.5, z: 50} m_Children: [] m_Father: {fileID: 833538478} m_RootOrder: 2 @@ -459,7 +459,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 241158957} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -25, y: 2, z: 22} + m_LocalPosition: {x: -50, y: 2, z: 45} m_LocalScale: {x: 1, y: 1, z: 5} m_Children: [] m_Father: {fileID: 1488444358} @@ -552,7 +552,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 432077771} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -35, y: 5, z: -20} + m_LocalPosition: {x: -63, y: 5, z: -37} m_LocalScale: {x: 10, y: 1, z: 10} m_Children: [] m_Father: {fileID: 942294095} @@ -645,7 +645,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 478907417} m_LocalRotation: {x: 0, y: 0, z: 0.38268343, w: 0.92387956} - m_LocalPosition: {x: 15, y: 7, z: 40} + m_LocalPosition: {x: 45, y: 7, z: 60} m_LocalScale: {x: 25, y: 5, z: 7} m_Children: [] m_Father: {fileID: 1833724898} @@ -832,7 +832,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 654784537} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -25, y: 2, z: -10} + m_LocalPosition: {x: -53, y: 2, z: -27} m_LocalScale: {x: 10, y: 1, z: 10} m_Children: [] m_Father: {fileID: 942294095} @@ -1017,7 +1017,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 717001268} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -25.5, y: 2, z: 36} + m_LocalPosition: {x: -49, y: 2, z: 58} m_LocalScale: {x: 14, y: 1, z: 7} m_Children: [] m_Father: {fileID: 1488444358} @@ -1403,7 +1403,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 858957125} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 80, y: 6.5, z: 0} + m_LocalPosition: {x: 155, y: 6.5, z: 0} m_LocalScale: {x: 75, y: 20, z: 0.25} m_Children: [] m_Father: {fileID: 1013482115} @@ -1666,7 +1666,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1194166061} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -36, y: 2, z: 25.5} + m_LocalPosition: {x: -59.5, y: 2, z: 47.5} m_LocalScale: {x: 7, y: 1, z: 14} m_Children: [] m_Father: {fileID: 1488444358} @@ -1823,7 +1823,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1509260413} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 28, y: 5, z: -23} + m_LocalPosition: {x: 49, y: 5, z: -42.5} m_LocalScale: {x: 10, y: 10, z: 10} m_Children: [] m_Father: {fileID: 746704017} @@ -1916,7 +1916,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1810553729} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -22, y: 2, z: 25} + m_LocalPosition: {x: -47, y: 2, z: 48} m_LocalScale: {x: 5, y: 1, z: 1} m_Children: [] m_Father: {fileID: 1488444358} @@ -2044,7 +2044,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1853948297} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 80, y: -3.5, z: 6} + m_LocalPosition: {x: 155, y: -3.5, z: 6} m_LocalScale: {x: 75, y: 0.25, z: 12} m_Children: [] m_Father: {fileID: 833538478} @@ -2137,7 +2137,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1943602250} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 19, y: 1, z: -21} + m_LocalPosition: {x: 40, y: 1, z: -40.5} m_LocalScale: {x: 10, y: 2, z: 10} m_Children: [] m_Father: {fileID: 746704017} @@ -2230,7 +2230,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2057687440} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -20, y: 10, z: -30} + m_LocalPosition: {x: -48, y: 10, z: -47} m_LocalScale: {x: 10, y: 1, z: 10} m_Children: [] m_Father: {fileID: 942294095} diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index dee5224..7b40d04 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -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);