Fixed issue where waypoint would spawn too close to previous waypoint location

This commit is contained in:
Gregory Campbell
2020-02-05 22:33:49 -05:00
parent fc24e21135
commit 46e500bfe6
+10
View File
@@ -24,6 +24,7 @@ public class WaypointRace : MonoBehaviour
private int selection = 0;
RaycastHit hit;
Vector3 lastLocation;
void Awake()
{
@@ -34,6 +35,7 @@ public class WaypointRace : MonoBehaviour
void Start()
{
lastLocation = new Vector3(0,0,0);
fullTime = Time.time;
gameOver = false;
script = player.GetComponent<PlayerController>();
@@ -56,6 +58,7 @@ public class WaypointRace : MonoBehaviour
if(script.finished == true)
{
lastLocation = groundedScript.transform.position;
waypointPlacement();
script.lives = 3;
level++;
@@ -86,6 +89,7 @@ public class WaypointRace : MonoBehaviour
{
script.lives = 3;
lastLocation = groundedScript.transform.position;
waypointPlacement();
}
@@ -196,6 +200,12 @@ public class WaypointRace : MonoBehaviour
{
waypointPlacement();
}
if((groundedScript.transform.position.x < lastLocation.x+50 && groundedScript.transform.position.x > lastLocation.x-50
&& groundedScript.transform.position.z < lastLocation.z+50 && groundedScript.transform.position.z > lastLocation.z-50))
{
waypointPlacement();
}
}
}