so I want 5 pair of two random number within a certain ratio and then printing the pairs ,but it skips the loops that don’t match the ratio instead of trying to get new numbers that match it. I don’t understand what I’m doing wrong plz help.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class test : MonoBehaviour
{
float r = 100;
float g = 40;
void Start(){
for (int i = 0; i < 5; i++){
float randX = Random.Range(r, g * i);
float randY = Random.Range(r * i, g);
if (randX >= randY){
if (randY/randX > .4 && randY/randX < .6){
Debug.Log("loop" + i + "fini");
Debug.Log(randY + "," + randX);
}else{
randX = Random.Range(r, g);
randY = Random.Range(r, g);
}
}else{
if (randX/randY > .4 && randX/randY < .6){
Debug.Log("loop" + i + "fini");
Debug.Log(randY + "," + randX);
}else{
randX = Random.Range(r, g);
randY = Random.Range(r, g);
}
}
}
}
}