Trouble with multiple doors in the one level

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Cobra!
:warning: Old Version Published before Godot 3 was released.

I’m having troubles with interacting with doors in my game, if there are multiple on one map and I open one, I cannot open any others until the one I opened has closed. They all use their own animation player, before anybody asks.

I have a temporary fix where the door closes itself after 2 seconds, but I obviously can’t finish my game with this.

Here’s the code below:

    extends Spatial

export(NodePath) var animationPlayer
onready var animation = get_node(animationPlayer)
export var open = false

const COOLER = 2
onready var timer = COOLER

func _ready():
	if open:"Appen")

func _process(delta):
	if open:
		if timer <= 0:"Close")
			open = false
			timer = COOLER
			timer -= delta

func activate(presser):
	if open:"Close")
		open = false
		open = true

After printing the open boolean of all the doors, I found that it’s setting all of the open values to true… I made open a private variable, but the problem persists.

I’m at a loss, how do I fix it?

How do you instance the doors? these seem to be sharing something.

A door scene like:

Door (script)

Should work fine.

Also, you can use the AnimationPlayer to work as a timer and turn a variable or call a function

ps: all variables are public in Godot

eons | 2017-05-01 04:01

I’m adding them as subscenes to a scene.

Cobra! | 2017-05-03 00:33

Is really weird, can you show the full scene structure (or relevant parts where doors are)?

eons | 2017-05-03 01:33

Okay, here: Screenshot by Lightshot

Cobra! | 2017-05-05 14:05

:bust_in_silhouette: Reply From: brunosxs

I don’t understand the reason to export the var animationPlayer. It seems unecessary(why whould you need two animation players?)
onready var animation = get_node(animationPlayer) would suffice.
My guess with this information is that you’re overcomplicating things by having the first var point to the animation player…

I’d simply use var animation = get_node("path/to_the_animation/player")

One of the animationPlayers is for the node_path point to the object, which I would set in the editor, and the other is the object itself.

Cobra! | 2017-05-05 13:59

I made it the one animationPlayer, and the problem persists…

Cobra! | 2017-05-05 14:03