Damage effects in Unity using animated sprites
May 22, 2021
In this demo, the procedure to attach an animated damage effect to show up upon a collision within two collider objects is demonstrated.
- Drag the damage sprite in the hierarchy, scale & place it as per choice and then make it a child of the game object where it should be displayed.
- Follow the same steps and attach the second effect as well.
- Declare two distinct damage variables as serialized and assign the game objects to them in the inspector.
// Damage Variable
[SerializeField]
private GameObject _rightDamage,_leftDamage;
- The method that handles penalties should set these game objects to active.
- Animate the game object and assign the animation to both of them. Note that you’d have to add an animator component to attach an animation that is applied to some other object.
Here is the final result :)
Thank you very much