# Having trouble with random value

First of all i know how to get random value with FastMath. I’m trying make mobs spawn randomly with:

``````node.setLocalTranslation(FastMath.nextRandomInt(-100, 100), 0, FastMath.nextRandomInt(-100, 100));
``````

But i don’t really want them to spawn between -100 and 100. i want them to spawn between; -100 and -90 OR 100 and 90.

I’ve kinda tried something like this:

``````node.setLocalTranslation(FastMath.nextRandomInt((-100,-90), (100,90)), 0, FastMath.nextRandomInt((-100,-90));
``````

I know this method doesn’t work like this.

Simply i want them to spawn around the house, not inside.

Is there any way/trick to make it happen?
i’ve tried few things but all failed.

U must swap the values around.

FastMath.nextRandomInt() Recieves minValue and MaxValue…

If you tell him that u want a value between [-100;-90], he gets confused. But between [-90;-100] he can pick one of 10 possible numbers!

Guess it will solve your problem!

-100 < -90

1 Like

Uh, my problem is not about getting confusing but i need random number between -100,-90 or 90,100. So there will be 20 possible number.

``````int random_n=FastMath.nextRandomInt(90,100);
if(FastMath.rand.nextBoolean())random_n=-random_n;
``````

or

``````int random_n;
if(FastMath.rand.nextBoolean())random_n=FastMath.nextRandomInt(-100,-90);
else random_n=FastMath.nextRandomInt(90,100);``````

Thank you