Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | oddbrisk |
Hi, I’m a beginner with Godot.
I’ve just finished following UmaiPixel’s Platformer Tutorial. I wanted to add a second attack, which is a stationary melee slash as opposed to a fireball projectile as shown in the tutorial.
In order to shorten the work time, I’ve duplicated the Fireball scene from said tutorial and adjusted it accordingly; same goes for the fireball attack code within the Player.
The desired effect is when I press the ‘slash’ attack button, utilizing the AnimationPlayer node, the slash animation will play, then once its finished, the attack as a whole will be ‘queue-freed.’
The issue I’ve come across is that although the attack is ‘queue-freed’ once the animation is finished, the animation itself plays way too fast in-game, almost like within a split-second.
Originally I thought that the duration of ‘0.4’ was the issue, so then I went and modified it to 1 second, and yet it still results in playing the animation way too fast in-game.
Here’s the code:
extends Area2D
var velocity = Vector2()
var direction = 1
func set_slash_direction(dir):
direction = dir
if dir == -1:
$Sprite.flip_h = true
func _physics_process(delta):
velocity.x = delta * direction
translate(velocity)
$AnimationPlayer.play(“slash”)
func _on_Slash_body_entered(body):
if “Enemy” in body.name:
body.dead(5)
queue_free()
func _on_AnimationPlayer_animation_finished(anim_name):
queue_free()