This content originally appeared on Level Up Coding - Medium and was authored by Calum Slee
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.
This content originally appeared on Level Up Coding - Medium and was authored by Calum Slee
Calum Slee | Sciencx (2021-05-12T17:06:07+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/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.