Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Procedural Content Generation for Unity Game Development

You're reading from   Procedural Content Generation for Unity Game Development Harness the power of procedural content generation to design unique games with Unity

Arrow left icon
Product type Paperback
Published in Jan 2016
Publisher
ISBN-13 9781785287473
Length 260 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Ryan Watkins Ryan Watkins
Author Profile Icon Ryan Watkins
Ryan Watkins
Arrow right icon
View More author details
Toc

Setting up sprites


We will now add enemy scripts and set up sprites.

First on our agenda is setting up the Enemy prefab and script. Let's take a look at the Enemy prefab. The prefab was imported with all of the starting materials in Chapter 2. Just in case you need an extra copy of the Enemy prefab though, there will be an import file in the accompanying Chapter 7 files.

The Enemy prefab looks a lot like the Player prefab. Both the Enemy and Player classes inherit from the Moving Object class. This means the enemy movement and animations are going to be processed in a similar way to the Player class. This generally means the prefab structure will have to be similar.

Enemy Sprite

Requirements for our Enemy prefab include:

  • A Sprite Renderer

  • An Animator

  • A Box Collider 2D

  • A Rigid Body 2D

  • The Enemy Script

Also, be sure that these options are selected in your Enemy prefab:

  • Set the tag to Enemy

  • Set the layer to BlockingLayer

  • In the Sprite Renderer component, set the Sorting Layer field to Units

  • In the Animator...

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
Banner background image