Need to make a the scene change different depending on which scene its in

Godot Version

4

Question

basically i want to make it sends you to a cutscene when they’re collided with, and that works, but since I’m using the same mob, it sends you to the same cutscene no matter which scene you’re in. i know there should be an else in there right? other than that i just don’t know what to put :frowning:

extends Node2D
@onready var parent = get_parent() as PathFollow2D

func _physics_process(delta):
	if parent is PathFollow2D:
		parent.set_progress(parent.get_progress() + 200 *delta)
	
		
func _on_area_2d_body_entered(area):
	if area.is_in_group("playe"):
		get_tree().change_scene_to_file("res://1st cutscene.tscn")
	else 

You can create an autoload node, like a GameManager, that would keep a track of which cutscene you’ve gone through already.

#GameManager.gd autoload
extends Node

var cutscene_index: int = 0

Then in your script do something like that:

func _on_area_2d_body_entered(area):
	if not area.is_in_group("playe"):
		return

	GameManager.cutscene_index += 1
	get_tree().change_scene_to_file("res://cutscene_%s.tscn" % GameManager.cutscene_index)

And change your cutscene scene file names to be “cutscene_1.tscn”, “cutscene_2.tscn”, etc. It will automatically load them in order.

this doesn’t work as you can go back to past levels (so it needs to be very specific to each individual scene). also when i applied it to my script the mobs no longer interacted properly with the player