0
\$\begingroup\$

I am working on a game where the player needs to open a door using a button.

A door open animation plays when the player clicks the button which triggers a keymap. So I used:

extends StaticBody3D

@onready var anim = $AnimationPlayer
@onready var col = $CollisionShape3D2
func _physics_process(delta: float) -> void:
        if Input.is_action_pressed("openLevel"):
                anim.play("doorAnim")
                col.disabled = true

But it starts playing automatically and keeps playing. I only want it to play the animation when the player clicks the button triggering "openLevel" keymap.

How do I fix this?

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

The first thing that comes to my mind is that you have the animation configured as Autoplay and loop. The second, some logic error in the code that triggers openLevel at the wrong time.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .