Individual scripts for different levels.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By kkaall


I am new to the godot engine so please forgive me if this is a very simple question.

So I am creating a game (2d platformer) that pretty much has the same level layout as every other level. However, each level has a trick to it. Say:
For level 1:

  • flick the lever (by pressing f) and a portal opens up.
  • enter the portal and go to next level (level 2)

For level 2:

  • flick the lever (by pressing f) 5 times and portal opens up.
  • enter the portal and go to next level (level 3)

For level 3:

  • flick the lever (by clicking with mouse cursor unlike level 1 and 2) and portal opens up.
  • enter the portal

etc etc.

So this is the layout for the game I’m developing. Problem is when I duplicate the level, the scripts (for lever, portal etc) don’t seem to be “individual” to each level node. Is there a way to make it such that each level node and its sub-nodes (like the lever for level 2 having a separate script to level 1’s lever)?

Thanks, and sorry again if this is a stupid question.

I’m not sure if you can have individual scripts, but the best you can do is in the script to check what scene this is.

rz | 2022-07-13 16:45

:bust_in_silhouette: Reply From: USBashka

In the bottom of Inspector tab you can find current script of the node and make it unique by pressing RMB and Make Unique.

However, I recommend to make individual scripts only for levels themself, when the items scripts will contain common functionality for that kind of items: like, the lever’s script contains input events and signal (or at least call function in) level script that lever was toggled. But you can do it whatewer you like.