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.

we collide with the player
when we get hit by the laser

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.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Suleiman Abdullah

Suleiman Abdullah

62 Followers

Self taught Unity Developer, who is passion about making games