Best practice for managing Autoload scripts (start screen vs. in-game)

My game – like most – has two contexts:

  • A) UI screens like start screen, credits or settings
  • B) The game itself with levels, players, items, etc.

I have various autoload scripts / singletons which mainly are for B):
For example one singleton adds the camera, another adds the health bar, yet another spawns the player.
They work perfectly there, but this also creates weird situations: E.g. The start screen now has a health bar.

→ So basically how to trigger the autoload in the right scenes / areas of the game and not in others?

What I am looking for:

  • I have many ideas already, but since this seems like a common problem …
  • … are there any best-practices on this topic? (e.g. an essay / tutorial)

Thanks in advance :v:

I would cut down on the auto loads, you can keep persistent player data in a autoload but I don’t think it should handle spawning in their camera and/or healthbar, I wouldn’t spawn the player by an autoload either.

You can hide or disable any autoloads in the start screen, they will still run _ready() functions though.

func _ready() -> void:
    camera.current = false
    healthbar.hide()
    player.set_process_mode = Node.PROCESS_MODE_DISABLED
1 Like

Thanks for your input :+1: