Hey, my question name is a little vague so here’s a better description of the problem I am facing:
I am making a 2D game in which a few circles are drawn onto random coordinates on the screen. The game gets the width and height of the device (ex: 1014,570) and then randomly chooses a coordinate for the circle (ex: 334, 201). My problem is that I don’t know how to place the circle to these numbers, all I can do is place a circle to a transform.x or a transform.y .
Here’s my code:
private float width,height;
public GameObject prefab;
public int circleCount;
void Start () {
width = Screen.width;
height = Screen.height;
for (int a = 0; a < circleCount; a++) {
float ranX = Random.Range(0,width);
float ranY = Random.Range(0,height);
Instantiate(prefab,new Vector3(ranX,ranY,0),transform.rotation);
}
}
Thanks in advance!