diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index 021d9b9..ccf7240 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -42,9 +42,11 @@ public class PlayerController : MonoBehaviour float slideTime = 0.0f; float wallRunTime = 0.0f; + float respawnTime = 1.0f; float oneSec = 1.0f; float halfSec = 0.5f; float quarterSec = 0.25f; + float tenthSec = 0.1f; void Start() { @@ -70,14 +72,14 @@ public class PlayerController : MonoBehaviour { velocity = new Vector3(0,0,0); - //moveDirection = new Vector3(0,0,0); + moveDirection = new Vector3(0,0,0); maxSpeed = 0; - if((Input.GetAxis("Horizontal") == 0 && Input.GetAxis("Vertical") == 0) || Input.GetButton("Stop")) - { - finished = true; - } - } + finished = true; + respawnTime = Time.time; + } else { + finished = false; + } } @@ -212,6 +214,7 @@ public class PlayerController : MonoBehaviour if (characterController.collisionFlags == CollisionFlags.None) { wallRunning = false; + //finished = false; wall = 0; } @@ -276,7 +279,10 @@ public class PlayerController : MonoBehaviour Debug.Log("Current Position: " + transform.position); // Move the controller - characterController.Move(velocity * Time.deltaTime); + if(finished == false && respawnTime + tenthSec < Time.time) + { + characterController.Move(velocity * Time.deltaTime); + } //Move the player in different directions based on camera look direction if(Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0) diff --git a/Assets/Scripts/ProceduralGeneration.cs b/Assets/Scripts/ProceduralGeneration.cs index 3e69c16..66ad927 100644 --- a/Assets/Scripts/ProceduralGeneration.cs +++ b/Assets/Scripts/ProceduralGeneration.cs @@ -12,6 +12,7 @@ public class ProceduralGeneration : MonoBehaviour public PlayerController script; public GameObject[] obstacleList; + private bool worldBuild = false; private int selection = 0; // Start is called before the first frame update @@ -20,6 +21,7 @@ public class ProceduralGeneration : MonoBehaviour script = player.GetComponent(); escalation = 1; + worldBuild = false; script.finished = false; script.transform.position = new Vector3((50*escalation)+100, 2, (50*escalation)+100); script.transform.Rotate(0.0f, 0.0f, 0.0f, Space.Self); @@ -34,21 +36,31 @@ public class ProceduralGeneration : MonoBehaviour if(script.finished == true) { + respawn(); escalation++; - levelBuild(); } + if(worldBuild == true) + { + levelBuild(); + } + + } + + void respawn() + { + + Debug.Log("Sent: " + new Vector3((50*escalation)+100, 2, (50*escalation)+100)); + script.transform.position = new Vector3((50*escalation)+100, 10, (50*escalation)+100); + script.transform.Rotate(0.0f, 0.0f, 0.0f, Space.Self); + worldBuild = true; + } void levelBuild() { - Debug.Log("Sent: " + new Vector3((50*escalation)+100, 2, (50*escalation)+100)); - script.transform.position = new Vector3((50*escalation)+100, 2, (50*escalation)+100); - script.transform.Rotate(0.0f, 0.0f, 0.0f, Space.Self); - Debug.Log("Player: " + new Vector3((50*escalation)+100, 2, (50*escalation)+100)); - GameObject[] oldObjects = GameObject.FindGameObjectsWithTag("Environment"); foreach (GameObject target in oldObjects) { GameObject.Destroy(target); @@ -79,8 +91,8 @@ public class ProceduralGeneration : MonoBehaviour Instantiate(obstacleList[0], new Vector3((50*escalation)+100, 0, (50*escalation)+100), Quaternion.identity); Instantiate(obstacleList[1], new Vector3(-((50*escalation)+100), 0, -((50*escalation)+100)), Quaternion.identity); + worldBuild = false; script.finished = false; - } }