I need help with random placement outside of edge of enemy in a game

I am having trouble with the placement of the zombie enemy in a new game i am making called Defender. The main objective of the game is to shoot the zombies and kill them so they don't get too close to you. I am still in the early stages of the game but i have already encountered a problem. The problem is with the placement of the zombies. I don't know how to get the clone of the zombies to start outside of the edge and i am asking for some help from the community to solve this issue.

With my low level of coding knowledge i have no idea how to solve this problem.
Any feedback would help!

Here is a link to the game

Isn't it just
untitled script pic (1)
(with whatever position you want them at)?

Yes but the thing is that i need them to go to a random position outside of the edge. The problem is, I don't know how to do that. I am not trying to get all the clones to go to a specific place on the map.

Here's my solution. This makes it so they always spawn at a random position outside the stage.

The distance variable is so you can quickly specify the distance from the stage you want them to spawn. I set it to 20 just for demonstration purposes.

Here's the project with this new code Snap! Build Your Own Blocks

Thank you so much for the help! It is really appreciated.

Long time no see (outside of school, of course)!
Also, is this the same zombie game you were making this morning? Because it kinda looks like it.
If so, I thought I told you I could help you tmr!

Sry I just needed help with that one issue i already fixed i have some ideas that you can help me with tho.

Hey i have one more issue with your fix, i was going to ask is you know why all of the zombies are only spawning on the top and the bottom of the screen.

It's because of this block here, you're picking the top or bottom for your Y coordinate for zombies

You can fix by randomly picking from a range or something like that

Alright, the issue is fixed, thanks everybody for your help!

In my script, the top half is setting the y, then the x, the second part (the else part) sets the x, then the y.

Thanks i realized my fault and fixed it

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.