Damage VFX Using Animated Sprites in Unity

Every time our Player loses a life, we should indicate this with VFX as well as our UI. For each life lost, we can “blow an engine” on each wing.Let’s position these two damage sprites as child objects of our player.Both will use the same animation and…

Every time our Player loses a life, we should indicate this with VFX as well as our UI. For each life lost, we can “blow an engine” on each wing.

Let’s position these two damage sprites as child objects of our player.

Both will use the same animation and controller so let’s create one and access it from both game objects.

In our Player script we need to create a variable to access our game objects. We can use an array to store them, as we may also want to add more damage indicators in the future. In our TakeDamage method we can use a switch statement to run the code for each amount of lives, rather than the if statement we had checking if we were dead. In this, we can simply use .SetActive to turn on our gameobjects accordingly.

Now, as our live’s decrease, our ship will appear to take more damage.


Damage VFX Using Animated Sprites in Unity was originally published in Level Up Coding on Medium, where people are continuing the conversation by highlighting and responding to this story.


Print Share Comment Cite Upload Translate
APA
Calum Slee | Sciencx (2024-03-28T22:49:57+00:00) » Damage VFX Using Animated Sprites in Unity. Retrieved from https://www.scien.cx/2021/05/12/damage-vfx-using-animated-sprites-in-unity/.
MLA
" » Damage VFX Using Animated Sprites in Unity." Calum Slee | Sciencx - Wednesday May 12, 2021, https://www.scien.cx/2021/05/12/damage-vfx-using-animated-sprites-in-unity/
HARVARD
Calum Slee | Sciencx Wednesday May 12, 2021 » Damage VFX Using Animated Sprites in Unity., viewed 2024-03-28T22:49:57+00:00,<https://www.scien.cx/2021/05/12/damage-vfx-using-animated-sprites-in-unity/>
VANCOUVER
Calum Slee | Sciencx - » Damage VFX Using Animated Sprites in Unity. [Internet]. [Accessed 2024-03-28T22:49:57+00:00]. Available from: https://www.scien.cx/2021/05/12/damage-vfx-using-animated-sprites-in-unity/
CHICAGO
" » Damage VFX Using Animated Sprites in Unity." Calum Slee | Sciencx - Accessed 2024-03-28T22:49:57+00:00. https://www.scien.cx/2021/05/12/damage-vfx-using-animated-sprites-in-unity/
IEEE
" » Damage VFX Using Animated Sprites in Unity." Calum Slee | Sciencx [Online]. Available: https://www.scien.cx/2021/05/12/damage-vfx-using-animated-sprites-in-unity/. [Accessed: 2024-03-28T22:49:57+00:00]
rf:citation
» Damage VFX Using Animated Sprites in Unity | Calum Slee | Sciencx | https://www.scien.cx/2021/05/12/damage-vfx-using-animated-sprites-in-unity/ | 2024-03-28T22:49:57+00:00
https://github.com/addpipe/simple-recorderjs-demo