How to spawn something in a random location within a specific area

exacly what the title is help plz

2 Likes

Doing you want it to spawn in specific spots randomly (set spawn points), or just any random spots within the arena?

To do the 2nd option use the Random behavior. You can set the X to the min and max of the arena, and that will be the X value used to spawn it.
Then do the same with the Y.

If you want a couple of set spawn points that it goes to randomly, I have an example I can send you. It’s on the forums called “Enemy Wave Example”, but it can be used in a non wave system as well.

1 Like

I was going to insert proper grammar into the title, but then I realized I didn’t know what it meant. Can you please explain your request?

1 Like

uhm exacly what the title says randomly spawning something randomly in an area

1 Like

i mean like if the rectangle is the entire area of the game i want to randomly have soemthing spawn in a square in the rectangle so not randomly spawning inside the rectangle but only the square

image

This is what I was talking about using the Random behavior. Find the range of the box, then set those as the X and Y values for the Random.

1 Like

i will try that i used emitters before but that take so much space and time

1 Like

actully i worded it a bit wrorng i wanted to spawn them randomly in an area like once every second

That’s what the code above does :+1: You can set the Timer to “Repeat Forever” then set the delay to whatever you’d like

slight issue tho when i hit play it spawns like 10 of them jk thats because i had many of same spawner block

im s o confused i cant find out where its spawning

What is the value in the Random behavior set to?
If you have your cursor over a grid placement, you should see a number like “4/7”
Multiply that by 32 and that is the X/Y of that grid space in pixels

right now its 200 200

Is this for both the X and Y? Having it set to 200 200 means it will spawn at 200 pixels, or grid space ~6

If you want a range you need to use separated values like 100 and 500, -200 and 200, etc.

yeah but first im trying to find out where it spawns

ok it is now spawning in sight

200 200 (assuming that’s for X and Y) should be near the left side of the screen.