2D Shooter: Thrusters and Engines
Objective: Add a thruster to the spaceship and spawn fires on the engines when the player takes damage.
For the thruster we want to drag the sprite onto the player object in the hierarchy so it becomes a child. Now it can be animated, and since its a child to the player object, wherever the player moves, the thruster will move too.
Do the same for the engines, make one, animate it, and place it where you want it as a child to the player object. Once one is done all you need to do is duplicate it and name the objects left and right engine respectively.
Now for the coding. Go to the player script and make a gameobject variable for both of the engines. Attach the objects to the corresponding boxes in the inspector, and now make sure that SetActive is set to false in the start method for both of the engines.
Now let’s make an if/else if statement in the damage method.
Now an engine should explode each time we get hit before we die!