The box enemies are the main mechanics for solving the puzzle in game. When you destroy a box it will spawn fire, time slower , or nothing depending on the box color.
In the image below the 3 boxes with 3 different colors will spawn different things.
1- Red = Fire ( it will create a block the player cant pass and do damage)
2- Purple = Time Slower Potion ( It will slow time in game)
3- Green = Nothing
Creating the boxes was an easy task but when the box get damaged it spawned the objects in another place though the script was spawning the object in the same position :
as you can see in the image below the potions didn’t spawn in the place of the box.
To fix this I noticed the destroy animation spawns the object in the right place so I had to add another Game Object in the script and give it the same script for the Destroy Effect and Leaving the Hurt Effect out.
instantiatedEffect.transform.localScale = transform.localScale;
New Script I had to leave the Scale to object out because it was not needed