Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Kakumi |
Hi,
I recently ran into a problem using AnimationPlayer.
I have 2 monsters on the map and when I kill the first one, there is no problem. Animation is played and at the end, monster is destroyed. But when I kill the second one during the animation of the first one, the first monster replay the animation from the start.
There is how it’s developed :
Entity is a main scene with Sprite and Animation Player (Has Entity.cs)
Bat inherits from Entity Scene (Has Bat.cs inherits Entity.cs)
When an entity died, the script inside Entity.cs call “PlayAnimation”.
if (_animationPlayer.HasAnimation("EntityDeath"))
{
_animationPlayer.Play("EntityDeath");
}
“EntityDeath” is an animation inside the Entity’s AnimationPlayer. This script load a ShaderMaterial (Local to scene activated) with a gdshader (Local to scene activated too) and play on a shader parameter
There is some logs details :
Entity Bat died
Bat Shader Progress : 0
…
Bat Shader Progress : 0.78
Entity Bat2 died
Bat Shader Progress : 0
Bat2 Shader Progress : 0
…
Bat Shader Progress : 1
Bat2 Shader Progress : 1
Hope you can help me !
Thank you
Can you post the code that implements the animation? I am not sure if there is enough here to pinpoint the issue. I doubt it is your shader if the animation is playing. Likely its something in the logic/implementation.
SnapCracklins | 2022-04-26 19:53
public virtual void Died()
{
if (!Dead)
{
Logger.Instance.Info($"Entity {Name} ({EntityName}) died");
Dead = true;
EmitSignal("Death");
if (_animationPlayer.HasAnimation("EntityDeath"))
{
_animationPlayer.Play("EntityDeath");
}
else
{
OnDeathAnimationEnd();
}
_name.Visible = false;
_hurtbox.Shape.SetDeferred("disabled", true);
}
}
AnimationPlayer : 1 hosted at ImgBB — ImgBB
Kakumi | 2022-04-27 14:46