Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Problem with calculating distance

$
0
0
So I'm trying to make a script that checks that a tagged object is still near it after three seconds. If it's still less than a certain distance away, the script will load the "completed" state for the level through a separate script called DataCenter. For whatever reason, though, once I added the distance calculation it started giving me null reference errors. Here's the code: var bulletObject : GameObject; var endStar : GameObject; function Update () { } function OnTriggerEnter(hit : Collider) { if(hit.tag == "Player") { yield WaitForSeconds (3); var distance = Vector3.Distance(bulletObject.position, endStar.position); if (distance > 3.0f) { DataCenter.allDestroyed=true; } } } The error is on line 14 Anyone have any idea why this might be happening? I'm still new to the coding side of game development.

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>