0 votes

I want to implement unique logic per level, and it seems that my code is quite cumbersome because I defined all the logic per level only on a single function of a single file. The levels are not to be changed; they will stay the same in the same scene.

Inside Main.gd

func _physics_process(delta):
    match level:
        1: ...
        2: ...
        3: ...

In every logic, I'm constantly changing the physics bodies' velocity so put it inside the _physics_process function.

I don't think if that's the good idea to get working with, but I think there's always a better one.

in Engine by (32 points)

1 Answer

0 votes

I would create a base Level scene that has the logic common to all levels, and then create scenes Level1, Level2, and so on which inherit from it. Each of these child scenes can have their own script attached with the logic specific to that level.

by (56 points)
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.