Learn to code by making a 2D space shooter game.
Objective: Implement Enemy Shields.
In the first step create a bool called is Shield Active and set it to default as true.
In the second step create gameObject for the shield named it the enemy shield.
In the next step drag the shield sprite, as a child of the smart enemy, then animate the shield sprite.
In the next step select a smart enemy, and drag the shield sprite to the inspector.
In the next step, we need to check if is shield active, if so we do nothing and set shield active to false.
In the next step, we need to disable our shield sprite when a player collides with us, or if we take a hit by a laser.
In the last step we need to make the smart enemy take one hit, we do this by using the return keyword which means get out of this triggerEnter method and don't proceed with other logic.
Let us see the final result.