O'Reilly logo

Practical Game Design with Unity and Playmaker by Sergey Mohov

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

Creating artificial intelligence

Having an artificial intelligence (AI) in the game, even a really simple one, will definitely make it more challenging and fun, so let us get to it with no further delay.

Here is how our AI is going to work: it is going to constantly try and move to the point on the right side of the puck, pushing it to the left upon collision. We will keep the same collision logic that we use for the player's mallet in order to keep the game fair. In order to make sure that the AI does not get stuck in a wall while pushing directly to the left, we will make adjustments to the direction based on the current position of the mallet. This way, the AI will appear to aim at the player's goal slot.

Follow the given steps to implement the ...

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