Right on target

Last but not least, let's look at how we get that target Quaternion. We know why we need it: because we have to feed a to Quaternion to the Slerp() function. To better understand the penultimate line, let's break it down like we did before.

var target : Quaternion = Quaternion.Euler (tiltAroundX, 0, tiltAroundZ);

We're creating a variable called target, which is a bucket. Then, we're putting something in that bucket that we know is going to be of type Quaternion. We're calling the Euler function of the Quaternion class and passing to it, three arguments.

Try typing Quaternion.Euler( into your Script, and reading the tooltip that pops up. The Euler function needs three arguments of type float. Notice also that there's a little page ...

Get Unity 4.x Game Development by Example Beginner's Guide 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.