I need help with double doors

Godot Version

4.7

I previously wrote a script for a single door, and now I want to reuse that script for double doors.

It worked, but there’s a small problem with the animation.

The only issue is that if I open one of the doors, both open. But if I try to close it using the other door, the opening animation restarts.

Both StaticBody share the same script.

extends StaticBody3D

var Open2 := false
var Interact2 := true
@export var Animation_Door: AnimationPlayer

func interact_door():
	if Interact2 == true:
		Interact2 = false
		Open2 = !Open2
		if Open2 == false:
			Animation_Door.play("close")
		if Open2 == true:
			Animation_Door.play("open")
		await get_tree().create_timer(1.0, false).timeout
		Interact2 = true

I need to make the door recognize when it’s open and when it’s closed, but I don’t know how.

If you @export the open variable you could assign it in the Animation.

Though I’d recommend making a new double-door script or fake the double-ness of the doors and only use one script

I forgot to mention, it’s a new scene.

The script is a duplicate of the previous script (in case I needed to modify it) and it has its own AnimationPlayer.

I figured the AnimationPlayer/animation was unique for this double door. I do believe the script could be attached to just one Static/AnimatableBody and have the animation play on both Collision shapes/mesh instances. With a scene tree like this.

It turned out perfect, thank you very much!!!

I changed it a little to make it easier to animate.