Hello! I have a really weird issue.
The following code is always printing the Debug.Log code. Even when distance is greater than range. Why is that if-statement always returning true? What am I missing? The Debug.Log always prints the distance and the range. If it is “1/10” that is correct since its below range. But it also prints “3242/10” if i stretch the objects apart. It’s never false.
Thanks in advance for any help!
private IEnumerator DoActions()
{
float distance;
while(target)
{
distance = Vector3.Distance(transform.position, target.transform.position);
if(distance < range);
{
Debug.Log (distance + "/" + range);
//Do things
}
yield return null;
}
}