Skip to content

Commit

Permalink
optimalisation
Browse files Browse the repository at this point in the history
  • Loading branch information
bozmir committed Dec 20, 2024
1 parent 3b3765b commit 7c9b2e9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Assets/Scripts/KerstSpecial/WorldAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ public class WorldAsset : MonoBehaviour
protected Vector3 startPosition;
protected Coordinate startCoord;

private RaceController raceController;

// Start is called before the first frame update
public virtual void Start()
{
raceController = FindObjectOfType<RaceController>();
startCoord = new Coordinate(CoordinateSystem.WGS84, lat, lon, 0);
Vector3 unityCoord = startCoord.ToUnity();
transform.position = unityCoord;
Expand All @@ -51,6 +54,13 @@ public virtual void Start()
// Update is called once per frame
public virtual void Update()
{
float dist = Vector3.Distance(raceController.playerCollider.gameObject.transform.position, prefab.transform.position);
if (prefab.gameObject.activeSelf && dist > 250)
prefab.gameObject.SetActive(false);
else if(!prefab.gameObject.activeSelf && dist < 250)
prefab.gameObject.SetActive(true);


if (!grounded && RaceController.isReadyToMove)
{
if (overrideHeight)
Expand Down

0 comments on commit 7c9b2e9

Please sign in to comment.