Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Unity 2017 Game AI Programming - Third Edition - Third Edition

You're reading from  Unity 2017 Game AI Programming - Third Edition - Third Edition

Product type Book
Published in Jan 2018
Publisher Packt
ISBN-13 9781788477901
Pages 254 pages
Edition 3rd Edition
Languages

Table of Contents (10) Chapters

Preface 1. The Basics of AI in Games 2. Finite State Machines and You 3. Implementing Sensors 4. Finding Your Way 5. Flocks and Crowds 6. Behavior Trees 7. Using Fuzzy Logic to Make Your AI Seem Alive 8. How It All Comes Together 9. Other Books You May Enjoy

Setting up the tank

The example project also includes a prefab for the tank, which is simply called (you guessed it) Tank, inside the Prefabs folder.

The tank itself is a simple agent with one goal: reach the end of the maze. As mentioned earlier, the player has to help the tank out along the way by activating its abilities to keep it safe from oncoming fire from the towers.

By now, you should be fairly familiar with the components you'll encounter along the way, except for the Tank.cs component attached to the prefab. Let's take a look at the code to figure out what's going on behind the scenes:

using UnityEngine; 
using System.Collections; 
 
public class Tank : MonoBehaviour { 
    [SerializeField] 
    private Transform goal; 
    private NavMeshAgent agent; 
    [SerializeField] 
    private float speedBoostDuration = 3; 
    [SerializeField] 
    private ParticleSystem...
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 €14.99/month. Cancel anytime}