Making the towers shoot

If we look back at our Tower component in the inspector, you'll notice that a prefab named bullet is assigned to the projectile variable. This prefab can be found in the Prefabs folder of the sample project. The prefab looks similar to the following screenshot:

The bullet prefab

The bullet game object is nothing fancy; it's just a bright yellow orb. There is a sphere collider attached to it, and, once again, we must make sure that IsTrigger is set to true and it has a Rigidbody (with gravity turned off) attached to it. We also have a Projectile component attached to the bullet prefab. This handles the collision logic. ...

Get Unity 2017 Game AI Programming - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.