Quantcast
Channel: Questions in topic: "loops"
Viewing all articles
Browse latest Browse all 184

DoWhile Loop is crashing Unity. Why?

$
0
0
The do while loop within the following script crashes Unity every time I try to run the scene. If I take the loop out of this script it runs fine, but with it in, Unity just freezes when I hit play. Any idea why? using UnityEngine; using System.Collections; public class FloorDistance : MonoBehaviour { public GameObject characterPos; public GameObject floorPos; Vector3 posChar; Vector3 posFloor; public float distance; void Awake () { posChar = characterPos.transform.position; posFloor = floorPos.transform.position; } void Update() { do { distance = Vector3.Distance(posChar, posFloor); } while(distance > 0f); Debug.Log(distance); } }

Viewing all articles
Browse latest Browse all 184

Trending Articles



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