Where to put all my input logic if I have different levels?

yep, concept is very important.

I have created one level scene, and from this I inherit every new one I create, for each level

and I have created the necessary variable for level

StartPoint is Player position in level
LevelTrigger set up next level

other objects are then assigned to a specific node( Background, Enemies .etc) and the logic is one and the same script for each level, no more needed

LevelTrigger is same logic in Level Scene

extends Area2D

export(String, "t1", "t2", "t3") var version = "t1"
export(String, "Classic", "Hard") var mode = "Classic"
export(String, "l1", "l2", "l3", "l4", "l5", "s") var scene = "l1"
export(String, "1", "2", "3", "i", "e") var stage = "1"

func _on_Trigger_body_entered(body):
	
	if body.is_in_group("player"):
		var _catch = get_tree().change_scene("res://levels/" + version + scene + stage + ".tscn")
		print("LOAD: res://levels/" + version + scene + stage + ".tscn")

I have all the levels stored in one place and I have a convention for naming them. Then I just compose the filename from the given variables and read the scene

:godot:

2 Likes