# Can anyone help me with a method i could used to create space or distance between spawns

Attention Topic was automatically imported from the old Question2Answer platform.

I have a code like this but im a facing a problem, my coins are overlapping each other

randomize()
for i in range(3):
Coins1.global_position.x = rand_range(-3500,6000)
Coins1.global_position.x = rand_range(-1000,650)
for i in range(1):
Coins2.global_position.x = rand_range(-3500,6000)
Coins2.global_position.x = rand_range(-1000,650)
for i in range(4):
Coins3.global_position.x = rand_range(-3500,6000)
Coins3.global_position.x = rand_range(-1000,650)
for i in range(2):
Coins4.global_position.x = rand_range(-3500,6000)
Coins4.global_position.x = rand_range(-1000,650)

Hi,

I am no expert but there may be a few problems with your code (cannot see the indent).

You are always changing position.x never y (might be normal for a platform).
You randomize once in the beginning. that could be the problem.
I would try to make a Global method for randomization :

``````func roll_dice(start, finish):
var rng = RandomNumberGenerator.new()
rng.randomize()
return rng.randi_range(start, finish)
``````

And call it everytime you need a random number. This way you should not have the same number:

``````Coins1.globalposition.x = Global.roll_dice(-3500,6000)
Coins1.globalposition.x = Global.roll_dice(-1000,650)
``````

Yet, you could also change the range according to previous coinspawn (to avoid having them too close, or too random), maybe by having a check like :
if a coin position is closer than 200, reroll dices.

Hope this helps.