0 votes

Hi there! I'm looking to make a moving platform that follows checkpoints, and I think it would be super easy to have that set up in an array, and since in the editor I can determine the size, would it be possible to auto fill that with the checkpoint node/scene and create a new instance each time?
enter image description here

Godot version 3.3.1 stable official
in Engine by (35 points)

ok so this code works how I want it to, it adds the checkpoint I want as it iterates, but the only problem now is that they only show up in code and the console. I want to be able to modify them while in a level so I can quickly design levels

 var i = 0 
        var size = checkpoints.size()
        while i < size:
            var check =  preload("res://Assets/Generic Platforms/checkpoint.tscn")
            var inst = check.instance()
            checkpoints[i] = inst
            i += 1

You will need to do


in order to actually see your checkpoint scene in-game.
Also, it might be more readable to use a for-loop in this case, like this:

for i in (checkpoints.size()-1): #rest of the code here

instead of a while loop.

thanks for the advice on the for loop, I tried that at first but something errored out. Either way what i'm wanting is for it to show up in the editor, not in game. I just want to be able to quickly set the array size to 3, have 3 objects show up in the editor, and me be able to position them in a level.
I think instead of that I think i can just drag the same scene into the object, and have them auto assign, which is slower sure but its beter than nothing

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.