O'Reilly logo

Learning Construct 2 by Aryadi Subagio

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Making enemies smarter

We created enemy objects in our example game earlier; these enemies are just falling down the screen and shooting, but now we will make cleverer enemies. The topic of AI is a complex one, and it is probably difficult to cover this topic in this chapter. So, instead of covering AI theories, I'll show you techniques that can make your enemies act smarter than usual.

Enabling enemy patrolling

The first thing we want to do to the enemies is to give them the ability to move around the screen, just like our own units. To do this, we'll first add a Timer behavior to the enemyBase object so that it can do something repeatedly. We also need to add an instance variable to it to record the state of the enemies; we don't want them to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required