|
|
|
 |
Reply From: |
Elis |
If you’re familiar with the method of load and instance, you can do something like:
var alpha = load("res://yourpath/map" + str(randi()%3 + 1) + ".tscn")
var alphainstance = alpha.instance()
add_child(alphainstance)
I hope it’s a solution to your problem
hello Ells , it’s me again
when I write the code in func _ready it woks only three times
I want its works infinitelly
it’s an infinity runner.
I create a collision shape (segmented), when my player collides on it
I want it creates ramdonly.
Hi CB
I’m not sure I understand your problem. If I’m right, you want to create a game with kind of the same mechanic as “Jetpack Joyride”, which create random scenes/environments every few screens. When working on a game, I would advise you to visualize what you want to do.
(Please keep in mind that it’s only how I would do it, but you can make your own better solution).

(It’s through the editor, not though)
I believe that with this way of doing it, your problem of the generation only working sometimes should disappear.
Does it seem right to you?
Btw, if you’re discovering the randi()% function, I would advise you to call randomize() at the start of your game, it will create a random set of number for your randi()% to use.
Hello Elis I’ve tried to do the way you’ve said
it worked
but each time the scene is created, it increases the velocity
forgive me, my english is very poor