I’ve been following a this Tutorial https://www.youtube.com/watch?v=q0WHhsmifkQ
and the colision wont disable after the input is pressed here’s the code if it will help
func _process(delta: float) → void: #animations
if (velocity.x > 1 || velocity.x < -1):
$Sprite2D.play(“walk”)
else:
$Sprite2D.play(“idle”)
if Input.is_action_just_pressed(“attack”):
$Sprite2D.play(“attack”);
attack = true;
$attackarea/CollisionShape2D.disabled = false;
I switched “$Sprite2D” to “$AnimatedSprite2D” Because from my knowledge… Sprite2Ds Don’t have a “.play()” thing, nor “.animation” thing, and i removed your ; because i don’t think they’re needed.
If my code doesn’t work then maybe do this code:
func _process(delta: float) -> void:
if velocity.x > 1 or velocity.x < -1:
$AnimatedSprite2D.play("walk")
else:
$AnimatedSprite2D.play("idle")
if Input.is_action_just_pressed("attack"):
$AnimatedSprite2D.play("attack")
attack = true
$attackarea/CollisionShape.disabled = false
func _on_animated_sprite_2d_animation_finished() -> void:
if $AnimatedSprite2D.animation == "attack":
$attackarea/CollisionShape.disabled = true
attack = false
Tell me if this worked!
Make sure to change your sprite2d to animated sprite2d, because that might play the animations (if your animations are already playing then no need to switch to animatedsprite2d)