The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

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:
            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?

in Engine by (171 points)

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

I'm adding them as subscenes to a scene.

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

1 Answer

0 votes

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")

by (234 points)

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.

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.