Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Unity 5.x 2D Game Development Blueprints

You're reading from   Unity 5.x 2D Game Development Blueprints Explore the features of Unity 5 for 2D game development by building three amazing game projects

Arrow left icon
Product type Paperback
Published in Sep 2016
Publisher Packt
ISBN-13 9781784393106
Length 252 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Francesco Sapio Francesco Sapio
Author Profile Icon Francesco Sapio
Francesco Sapio
Abdelrahman Elsayegh Abdelrahman Elsayegh
Author Profile Icon Abdelrahman Elsayegh
Abdelrahman Elsayegh
Arrow right icon
View More author details
Toc

Enemies


In this section, we will learn how to create the enemies for our Tower Defense game.

Creating the enemy prefab

Since we will see how the game manager will spawn a lot of enemies later, in Chapter 9, Finishing the Game, we need to create a prefab to store all the data for one enemy, including its graphics, components, and scripts.

By right-clicking on the Hierarchy panel, we can select 2D Object/Sprite in order to create a new Sprite. Of course, we need to assign the graphic and adjust its dimensions to fit our game environment. In this case, we can chose the slime_red as our enemy. Like the previous components, towers and bullets, it also needs to be scaled. In this case, we can set the whole scale vector to 0.8. Furthermore, we should set the value of the Z-axis, for the position, to -1. Once we have done this, it should look like this:

In order to be detected by the towers, our enemy should have the enemy tag. Since we have already created this tag in the bullet section, it can easily...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime