Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Matteo |
Hi guys,
I have a problem, i’m doing a character that can shoot some fireballs,
i coded it that he can shoot a fireball only when the animation frame reaches the number 5.
The problem is that when I shoot it create not only one fireball, but more than one.
What is the problem? Thank you in advance
This is the code I used:
func fire_attack():
if Input.is_action_pressed("attack") and is_on_floor() and movimento.x==0 and fire_power_up==true:
$AnimatedSprite.play("fire_attack")
$AnimatedSprite.set_speed_scale(2)
if $AnimatedSprite.get_frame()==5:
var fireball= preload("res://scenes/magics/fireball.tscn").instance()
get_node("..").add_child(fireball)
fireball.global_position=$fire_spawn.global_position