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:
Gregory Campbell
2020-01-11 00:46:40 -05:00
parent e801bfe945
commit 15521e4a4c
3 changed files with 24 additions and 15 deletions
+10 -4
View File
@@ -68,10 +68,16 @@ 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);