Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | tellheim |
Hi there I am glad to be here. I am new to Godot and normally I come from the theater and I am doing 3D stuff. But now I tried out this game engine, and I love it. But I have a problem since two days, as written above. Although a function is working, and the debugger has no warnings or so, the engine “jumps” one code - line. The code is this one:
func toedlich():
if is_alive == true:
$AnimatedSprite.play(“Dumm_gelaufen”)
yield($AnimatedSprite, “animation_finished”)
is_alive = false
queue_free()
everything is executed, except the line with the AnimatedSprite. It even holds the yield for the time, the animation would need to run. But it does not play it… I am absolutely confused. If there are any ideas, thank you very very much…
tellheim
(Sorry for the English, its not my mother language…)
i suppose the issue is in the node, not the code, what parameter are you trying to animate?
Andrea | 2021-03-17 16:20
the node is a kinematic body. maybe it is better to understand, if I post the whole code:
for explanation: “Flint” is the player
extends KinematicBody2D
export var gravity = 400
var movement = Vector2()
var UP_Vector = Vector2(0, -1)
export var speed = 200
export var jump = 250
onready var spriteFlint = $AnimatedSprite
var is_alive = true
#–> signale
func _on_HarmlosArea2D_body_entered(body: Node) → void:
is_alive = false
harmlos()
func _on_Hit_Box_Bomb_area_entered(area: Area2D) → void:
is_alive = false
toedlich()
#<— Ende signale
#-----> Physics Prozesse Flint
func _physics_process(delta):
movement.x = 0
movement.y += gravity * delta
#–> Verhindert, dass Gravitation sich multipliziert oder dass man an der Decke kleben bleibt
if is_on_ceiling() or is_on_floor():
movement.y = 0
#<-- Ende verhindert, dass Gravitation sich multipliziert oder dass man an der Decke kleben bleibt
_check_key_input()
movement = move_and_slide(movement, UP_Vector)
#<-----Ende Physics Prozesse Flint
#–> funktionen
func toedlich():
if is_alive == false:
spriteFlint.play(“Dumm_gelaufen”)
yield(spriteFlint, “animation_finished”)
is_alive = true
die()
func harmlos():
if is_alive == false:
spriteFlint.play(“Flint_Faellt”)
yield(spriteFlint, “animation_finished”)
is_alive = true
#------> Steuerung Flint
func _check_key_input():
if Input.is_action_pressed("walk_left") && is_alive == true:
spriteFlint.flip_h = true
movement.x = -speed
if Input.is_action_pressed("walk_left") && is_on_floor() && is_alive == true:
spriteFlint.flip_h = true
movement.x = -speed
spriteFlint.play("Flint_Walk")
if Input.is_action_pressed("walk_right") && is_alive == true:
spriteFlint.flip_h = false
movement.x = speed
if Input.is_action_pressed("walk_right") && is_on_floor() && is_alive == true:
spriteFlint.flip_h = false
movement.x = speed
spriteFlint.play("Flint_Walk")
if Input.is_action_pressed("jump") && is_on_floor() && is_alive == true:
movement.y = -jump
spriteFlint.play("Flint_Jump")
if movement.y > 10:
spriteFlint.play("Flint_Jump")
#if Input.is_action_pressed("up") && is_on_floor() && is_alive == true:
#movement.y = -jump / 2
#spriteFlint.play("Flint_Climb_Up")
if movement.x == 0 && movement.y == 0 && is_on_floor() && is_alive == true:
spriteFlint.play("Flint_Idle")
#<----Ende Steuerung Flint
func die() → void:
SpielerDaten.deaths += 1
queue_free()
tellheim | 2021-03-17 16:31