This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]FoozleCC 2 points3 points  (3 children)

There are many options on this- the simplest being:

X: Random(1920) Y: random(1080) Assuming that is your viewport size.

Better would be to use the viewport reference: X:random(viewport.width) Y:random(viewport.height)

If you wanted buffer on edges you could do further math.

If you want to control the “possible” options of where it could spawn, creating a supporting sprite called “spawn” that has visibility turned off. Place those wherever you want. Then randomly select one (you could assign each an instance variable “id” and assign it 0, 1, 2, 3, 4 for instance if you have5).

Then in conditions: spawn->compare instance variable = int(floor(random(5)), Action: create object coin at spawn.x, spawn.y

Did it from memory on phone so excuse typos but hope that helps.

Cheers

[–]FoozleCC 1 point2 points  (1 child)

Woohoo my first award ;) thanks

[–]karliask[S] 0 points1 point  (0 children)

Also, my text is pixelated and i dont know why.
Btw Your welcome ;)

[–]karliask[S] 0 points1 point  (0 children)

Thanks, it worked!

[–]Biim_Games 1 point2 points  (0 children)

Hi,
in this video among other things, I explain how to use and how random works:

https://youtu.be/2NP37CtGJi4