![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Dek0521 |
Godot Engine v3.0.2
2D
GDScript
Hello I’m new to Godot coming from unity, and I’m Stuck on 2D Animations with a delay. I Understand basic animations in Godot but what if a have a multi-frame death animation where the character falls over then dies, I’ll need to play the animation then disable the node after the animation is finished. My Question is how do you add that delay in your animation? in unity i would just use a simple coroutine and
yield return new WaitForSeconds(Animation.Length) ;
Destroy(gameObject);
I just can’t seem to figure out how to do this in the Godot Engine, currently I’m working on a simple 2D Platformer and i have a multi frame jump animation that i want to use.
I can’t get my animated sprite node to play the animation and then jump, so the first frame of the animation is the sprite that jumps in the air when the player presses up. The desired effect is to play all frames of the jump animation once, then jump when the animation is finished. The last frame should be the frame the player jumps in the air with. here is my GDScript:
extends KinematicBody2D
var movement = Vector2() #holds direction player is moving
export var speed = 350 #player speed
export var jump = -600 #jump height
export var gravity = 20 #gravity modifier
const UP = Vector2(0, -1) #constint variable holding up direction
func _physics_process(delta):
movement.y += gravity
print (gravity)
if Input.is_action_pressed("ui_right"):
movement.x = speed
$Sprite.flip_h = false
$Sprite.play("Run")
elif Input.is_action_pressed("ui_left"):
movement.x = -speed
$Sprite.flip_h = true
$Sprite.play("Run")
else:
$Sprite.play("Idle")
movement.x = 0
if is_on_floor():
if Input.is_action_pressed("ui_up"):
$Timer.start() #Tried using timer for jump delay but now animation # plays but player does not leave the ground
$Sprite.play("Jump")
if $Timer.is_stopped():# Timer is set to, One Shot = true, Wait Time # = 3, Process Mode = Idle, Autostart = false in Godot Engine
movement.y = jump
movement = move_and_slide(movement, UP) #moves player
pass
Any Ideas how to get this jump animation working properly? Thanks in advanced