Fixed issue where waypoint would spawn too close to previous waypoint location
This commit is contained in:
@@ -24,6 +24,7 @@ public class WaypointRace : MonoBehaviour
|
|||||||
private int selection = 0;
|
private int selection = 0;
|
||||||
|
|
||||||
RaycastHit hit;
|
RaycastHit hit;
|
||||||
|
Vector3 lastLocation;
|
||||||
|
|
||||||
void Awake()
|
void Awake()
|
||||||
{
|
{
|
||||||
@@ -34,6 +35,7 @@ public class WaypointRace : MonoBehaviour
|
|||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
lastLocation = new Vector3(0,0,0);
|
||||||
fullTime = Time.time;
|
fullTime = Time.time;
|
||||||
gameOver = false;
|
gameOver = false;
|
||||||
script = player.GetComponent<PlayerController>();
|
script = player.GetComponent<PlayerController>();
|
||||||
@@ -56,6 +58,7 @@ public class WaypointRace : MonoBehaviour
|
|||||||
if(script.finished == true)
|
if(script.finished == true)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
lastLocation = groundedScript.transform.position;
|
||||||
waypointPlacement();
|
waypointPlacement();
|
||||||
script.lives = 3;
|
script.lives = 3;
|
||||||
level++;
|
level++;
|
||||||
@@ -86,6 +89,7 @@ public class WaypointRace : MonoBehaviour
|
|||||||
{
|
{
|
||||||
|
|
||||||
script.lives = 3;
|
script.lives = 3;
|
||||||
|
lastLocation = groundedScript.transform.position;
|
||||||
waypointPlacement();
|
waypointPlacement();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -196,6 +200,12 @@ public class WaypointRace : MonoBehaviour
|
|||||||
{
|
{
|
||||||
waypointPlacement();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user