Project B | Box Enemies

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

boxestypes

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 :
//Instantiate(HurtEffect,instigator.transform.position,transform.rotation);

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.
var instantiatedEffect=(GameObject)Instantiate(DestroyEffect,transform.position,transform.rotation);
instantiatedEffect.transform.localScale = transform.localScale;
script-before

New Script I had to leave the Scale to object out because it was not needed
script-now

 

 

One thought on “Project B | Box Enemies

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s