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

Placing the towers


When the player buys a tower, they have the possibility to place it where they want. In order to include this feature inside our game, we need to make some changes to our towers.

Allowed areas

To begin with, we should notice that the player is not free to place their towers wherever they want to on the map. In fact, they cannot place them along the path where the enemies are moving or in areas where there is water. Therefore, we need to implement this constraint.

Thus, we need to look at our map and find all the spots where the player can place the tower. In our case, the spots that we are looking for are the following:

As we can see, it has a custom shape. Even if it is possible to implement a custom shape, it can be much more convenient to think in terms of rectangles and then to split our shape into rectangles. Of course, this can be done in more than one way; however, using fewer rectangles to cover the entire area is better. On the other hand, by using more rectangles...

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 $19.99/month. Cancel anytime