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.


