How to make child scenes unique

Hello,

I’m new to Godot and trying to make a 3d game. I have a main scene in which I import child scenes as objects.

The child scene in question is a door. I have a script in that scene that detects if the player is inside an aera3d and, if so, play an opening animation if the user click on the right mouse button.

It works well but if I add multiple door child scenes to the main scene, when the user click all doors open. I think it has to to do with the make unique parameter but I haven’t been able to make it work.

Here is my script:

extends Node3D

var player_infront := false
var player_present := false
var door_closed := true
@export var locked: bool = false
var from_end: bool = false


func _input(event: InputEvent) -> void:
	if Input.is_action_just_pressed('primary'):
		if player_present and !$AnimationPlayer.is_playing():
			if door_closed and !locked:
				door_closed = false
				if player_infront:
					$AnimationPlayer.play('Ouverture')
				else:
					$AnimationPlayer.play('Ouverture_2')


func _on_detection_zone_body_entered(body: Node3D) -> void:
	player_present = true
	player_infront = true

func _on_detection_zone_body_exited(body: Node3D) -> void:
	player_present = false
	player_infront = true

func _on_leave_zone_body_exited(body: Node3D) -> void:
	player_present = false
	if !door_closed:
		door_closed = true
		if $AnimationPlayer.is_playing():
			await $AnimationPlayer.animation_finished
		if player_infront:
			$AnimationPlayer.play('Fermeture')
		else:
			$AnimationPlayer.play('Fermeture_2')


func _on_area_3d_body_entered(body: Node3D) -> void:
	player_present = true
	player_infront = false


func _on_area_3d_body_exited(body: Node3D) -> void:
	player_present = false
	player_infront = false

And the child scene:

Thank you for your help!

It’s probably because your doors are all set to player_present to start, the body_entered signal is for any body, so the door is detecting itself when the game starts (unless you’ve altered the collision layers/masks).

In your body_entered/exited functions check if it’s the player either by class_name through is or by node name

func _on_detection_zone_body_entered(body: Node3D) -> void:
	if body is Player: # assuming player have a `class_name Player`
	#if body.name == "Player": # otherwise you can detect by the player node's Name
		player_present = true
		player_infront = true

Thank you for your answer, that works!