Phase II Progress Report — New enemy– Sniper

In this article, I will discuss the new enemy I have added, the sniper.

The sniper enemy stays at the top of the screen to avoid direct collisions with the player and will shoot accurate bolts at the player and powerups alike.

The sniper is a rare spawn but can cause a lot of pain if not taken out early.

The implementation of the enemy was quite simple. For the movement, I randomly assign a Y height for the enemy.

It then makes its way to this point with a check to see when it arrives.

When it arrives at the correct height it activates another function which makes allows the sniper to strafe between its min and max range on the x-axis.

The enemy casts a ray when it is able to attack. This ray looks for powerups and players and fires a shot when one is found. After every shot, there is a random cool-down period before each next shot.

Now we see it in action.

That's all for now.

--

--

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
Luke Duckett

Luke Duckett

Unity developer with a love of learning all things programming.