Scripting the FlyController Component

Before we can make the necessary changes to our FlightPoints script in order to allow an enemy to change its facing direction, we need to first create the FlyController script, as shown in Listing 9.11.

Listing 9.11 The FlyController Script

public class FlyController : EnemyController{}

That’s it. No, really, that’s all there is to this script. All we need to do is point it to the EnemyController so that our Fly inherits the Flip() function. We also inherit the “Max Speed” property, but that won’t affect our Fly, as its speed is derived from the FlightPoints Component instead.

Tip

It may seem pointless to create a script like this, but if we ever wanted to provide unique functionality ...

Get Learning 2D Game Development with Unity®: A Hands-On Guide to Game Creation 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.