Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Cobra! | |
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:
animation.play("Appen")
set_process(true)
func _process(delta):
if open:
if timer <= 0:
animation.play("Close")
open = false
timer = COOLER
else:
timer -= delta
func activate(presser):
if open:
animation.play("Close")
open = false
else:
animation.play("Open")
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)
|-AnimationPlayer
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