How to Spawn object within certain boundary


I want to make a game where i spawn objects randomly within a certain boundary–lets say within the middle section of the screen. The thing is, the screen resolution will change depending on what phone is playing it (e.g. an iPhone 11 against a Samsung Note 10), so I’d rather use relative numbers vs exact pixel measurements, for consistency. How can I achieve this?


in the “create object” action’s parameters, you can set up a RandomInRange() expression as a X() and Y() position to the newly created object. other words, you can set up a boundary box for spawning.


hmm, i see. thanks. how can i make the boundary box in the middle of the screen without using pixel measurements?


how do you think GDevelop will know where the middle is if you don’t measure it?!
by the way you can use expression inside of… an another expression. WoW :open_mouth: it’s amazing, isn’t it?