Currently, when the player kills a demon, the demon just vanishes with no effect. For a more fun and visual alternative, I used a dissolve shader. There was a compromise for this, as using a shader meant that I would loose any detail to the enemy. But, as there is no demon texture, I thought I’d accept this compromise.
I found this post online and decided to use it in order to create the shader.
The shader took 3 textures as inputs. One of which I used from the website however the others I created.
I made 2 new 500x500px Photoshop files. The first I filled in a dark navy blue colour, and the other filled a vibrant yellow.

The ‘Slice Amount’ slider is the variable that I can adjust in order to change how much the mesh dissolves.
I then created a new animation clip on the enemies Animator called ‘DissolveDemon’. By pressing record, I was able to move the play head to 2 seconds and change the ‘Slice Amount’ to 1. This creates an animation that starts with no dissolve, and ends with a full dissolve.
In the EnemyController script, I changed where I initially destroyed the GameObject and played the animation instead.
if (currentHealth <= 0)
{
animator.Play("DissolveDemon");
I still wanted to destroy the object though, so I created a new method called Die where I’d actually remove the game object from the scene.
void Die()
{
Destroy(gameObject);
}
Finally, I added an animation event that calls the Die method when the animation ends.


By doing this, the game saves memory by clearing the used game objects and also allows other scripts to work, such as the PlayerLockOnSystem.
Leave a Reply