Added the resetting of a level after player reaches the end, encountered strange bug that causes player to not teleport back to start
This commit is contained in:
@@ -606,7 +606,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 7e52a505534642144b4f939196badbab, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
escalation: 1
|
||||
escalation: 0
|
||||
player: {fileID: 1644583839}
|
||||
script: {fileID: 1644583840}
|
||||
obstacleList:
|
||||
|
||||
@@ -68,9 +68,15 @@ public class PlayerController : MonoBehaviour
|
||||
|
||||
if(hit.gameObject.tag == "Finish")
|
||||
{
|
||||
finished = true;
|
||||
|
||||
velocity = 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -261,14 +267,14 @@ public class PlayerController : MonoBehaviour
|
||||
|
||||
velocity.y = moveDirection.y;
|
||||
|
||||
Debug.Log(moveDirection.y+"\n");
|
||||
|
||||
if(moveDirection.y <= -5 && Mathf.Abs(velocity.x) <= 1.5f && Mathf.Abs(velocity.z) <= 1.5f)
|
||||
{
|
||||
velocity.x = velocity.x * Mathf.Abs(moveDirection.y);
|
||||
velocity.z = velocity.z * Mathf.Abs(moveDirection.y);
|
||||
}
|
||||
|
||||
Debug.Log("Current Position: " + transform.position);
|
||||
|
||||
// Move the controller
|
||||
characterController.Move(velocity * Time.deltaTime);
|
||||
|
||||
|
||||
@@ -21,6 +21,9 @@ public class ProceduralGeneration : MonoBehaviour
|
||||
script = player.GetComponent<PlayerController>();
|
||||
escalation = 1;
|
||||
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);
|
||||
script.pivot.transform.Rotate(0.0f, 225.0f, 0.0f, Space.Self);
|
||||
levelBuild();
|
||||
|
||||
}
|
||||
@@ -31,8 +34,7 @@ public class ProceduralGeneration : MonoBehaviour
|
||||
if(script.finished == true)
|
||||
{
|
||||
|
||||
escalation++;
|
||||
|
||||
escalation++;
|
||||
levelBuild();
|
||||
|
||||
}
|
||||
@@ -42,6 +44,11 @@ public class ProceduralGeneration : MonoBehaviour
|
||||
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);
|
||||
@@ -62,6 +69,9 @@ public class ProceduralGeneration : MonoBehaviour
|
||||
|
||||
selection = Random.Range(2, obstacleList.Length);
|
||||
Instantiate(obstacleList[selection], new Vector3(50*i, 5, -50*j), Quaternion.identity);
|
||||
|
||||
script.transform.position = new Vector3((50*escalation)+100, 2, (50*escalation)+100);
|
||||
script.transform.Rotate(0.0f, 0.0f, 0.0f, Space.Self);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -69,15 +79,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);
|
||||
|
||||
player.transform.position = new Vector3((50*escalation)+100, 2, (50*escalation)+100);
|
||||
player.transform.Rotate(0.0f, 225.0f, 0.0f, Space.Self);
|
||||
script.finished = false;
|
||||
|
||||
if(escalation == 1)
|
||||
{
|
||||
script.pivot.transform.Rotate(0.0f, 225.0f, 0.0f, Space.Self);
|
||||
}
|
||||
|
||||
script.finished = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user