O'Reilly logo

Developing AR Games for iOS and Android by Dominic Cushnan, Hassan EL Habbak

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

Scripting the mole character

Now that iTween is in place, let's see how we can script the mole character to make use of iTween and animate the character correctly. What we are aiming to achieve with the mole script at this stage is to have it animate up and down from the molehill. The animation should start at a random time between two ranges to avoid repetition and predictability of the behavior.

Let's take a look at how this script looks like. The following screenshot shows moleAnimator.cs script:

Scripting the mole character

The first three lines in the Start() function are quite simple. We find and attach the mole hit sound source to moleHitAudio to be used by us in the script. ...

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