func _ready():
var timer = Timer.new()
timer.wait_time = 1.7
timer.auto_start = true
add_child(timer)
timer.timeout.connect(_on_timer_timeout)
func _on_timer_timeout():
randomize()
var coin = preload("path/to/your/coin.tscn").instantiate()
coin.position.y = -25 #Replace it by the top position of screen
coin.position.x = randf_range(-40, 40) #replace by start and end of screensize
add_child(coin)
When you paste this code in the script, press CTRL + S.
If you need far help from me as a friend then contact me on discord, king_game_developer
wow, this is awesome! I was just thinking about trying to make a “catch falling object” type game in Godot (noob) and this is a great start of code to use and play around with! Do you by any chance have an updated project of this ‘game’ you were working on to share?
And, if you have/want to randomly spawn multiple falling objects a various places on a hoizontal line (for the character to move and try to catch/collide with) is that just a matter of copy paste of the “coins” node in your screenshot above?