How do you spawn an object in a random place in a set area?,How do you spawn a set object in a random location in a set area

im making an endless dodging game and i need the obstacles to spawn randomly on the right of the screen

Can anyone help? i program in c#
thanks :slight_smile:

You can use

Vector 2 randomPosition = new Vector2(Random.Range(0, 10), Random.Range(10, 20));

where the parameters are x and y (horizontal and vertical)
If you want to make random position from a given point you can just add this position as

transform.position + new Vector2...