简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
Help us translate Steam
Find, play, and make games easily
Discover, rate, and download the best player-created games made in
for free. Or try making your own and share with the community. Click
to learn more.
Nov 22, 2012 @ 12:46am
How to make things randomly drop from the sky?
I am trying to get comets to drop randomly in my game but i cant figure out how. i tried the create random instance and making the direction they move down but they never appeared. any help would be appreciated.
Nov 22, 2012 @ 6:49am
Try using instance_create(x,y,object) (horizontal position, vertical position, object name)
If you use it with a random X of a range up to the room width aka random(room_width) and putting 0 for y (so it's at the top), this will probably succeed.
The full instance create code is: instance_create(random(room_width),0,obj_meteor)
Replace obj_meteor with your meteor object!
Every time you call this code a meteor will be created. So it's up to you now how to call this code and how often!
Nov 22, 2012 @ 11:37pm
ok. ill try it. thanks.
Nov 23, 2012 @ 10:58am
I'd add that you want to use irandom(x) and not random(x) or else it'll flash due to being at a fraction of a pixel.
Nov 25, 2012 @ 10:47pm
Put this into an alarm or step function and modify it to your needs.
// This is a dice of 20 sides, if you want a higher chance, lower the number
if ( irandom_range( 0, 20 ) == 0 )
// Get a random location with a little border in the size of the sprite
xpos = irandom_range( sprite_get_width(sprite_index), room_width - sprite_get_width(sprite_index) );
// Spawn outside the players view, so it comes in smoothly and does not pop up
new_obj = instance_create( xpos, -sprite_get_height(sprite_index), objMyFallingStuff);
direction = 270; // direction downwards
speed = 20;
Last edited by
; Nov 25, 2012 @ 10:49pm
Per page: 15
Nov 22, 2012 @ 12:46am
Start a New Discussion
Discussions Rules and Guidelines
Crashing after testing
Looking for an artist for December Competition
(resolved but still needs fixing) Game not updating in steam workshop
Dealing with ramps in a platformer
Report this post
Note: This is ONLY to be used to report spam, advertising, and problematic (harassment, fighting, or rude) posts.
© Valve Corporation. All rights reserved. All trademarks are property of their respective owners in the US and other countries.
Some geospatial data on this website is provided by
Steam Subscriber Agreement
View mobile website