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?