O'Reilly logo

Unity 3D Game Development by Example by Ryan Henson Creighton

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

One final tweak

One small adjustment stands between you and a fun keep-up game mechanic. We want the paddle to angle in the opposite direction to keep the ball bouncing inside the play area. Instead of multiplying by 2, we can multiply by -2 to flip the effect:

var tiltAroundX = Input.GetAxis("Mouse Y") * tiltAngle * -2;

Save and test. Hooray! The paddle tilts around the play area inclusively, keeping the ball more or less within our reach unless we get twitchy, and then we drop the ball. But that's the fun of keep-up moving the paddle just so to keep the ball in play.

What's a quaternion?

Well, that was lots of fun! We've got a working keep-up game mechanic. Now let's go and do something else.

Wait, what's a quaternion?

Oh, that? Don't worry about ...

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