07.12.2012 Views

Adobe Director Basics

Adobe Director Basics

Adobe Director Basics

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

ADOBE DIRECTOR BASICS<br />

3D: Controlling action<br />

Controlling forward movement<br />

This technique will work regardless of how the movement of the camera's parent node is controlled. See “Steering with<br />

the mouse” on page 221 for more details.<br />

Advantages of using a parent node<br />

This technique relies on the camera being attached as a child to a parent node. The parent node is moved around and<br />

the camera follows. Why not just move the camera around on its own?<br />

Here are the reasons:<br />

The worldPosition of the parent node determines the point of departure of the ray used by modelsUnderRay().<br />

This needs to be at the same height as the barrier models. It is often simpler to place the barriers with their center<br />

at y = 0, even though the camera may need to be at a different height.<br />

The parent node's zAxis can always face forward, and remain perpendicular to the world's yAxis. You can tilt and<br />

swivel the camera and change its height independently of its movement over the terrain. See “Looking around” on<br />

page 222 for more details.<br />

Steering with the keyboard<br />

You may prefer to use the keyboard to move around inside the 3D world. Two common arrangements are to use the<br />

arrow keys with the right hand or to use the W, A, S and D keys with the left hand.<br />

To experiment with using the keyboard to move around inside a 3D scene, download and launch the movie<br />

KeyboardControl.dir.<br />

Use the arrow keys with your right hand or the WASD keys with your left hand to control the camera.<br />

The KeyboardControl.dir movie contains a parent script called Steer With Keyboard. This script uses the keyPressed()<br />

function once per frame to determine whether the user is pressing certain keys. If so, it moves the parent node of the<br />

camera.<br />

Turning<br />

Here is a simple handler which checks whether any of the keys associated with turning have been pressed. If so, it<br />

rotates a node called aCameraParent around its own yAxis. For this to work correctly, the yAxis of aCameraParent<br />

must be aligned with the up axis of the world. You can find a similar handler in the Steer With Keyboard script in the<br />

KeyboardControl.dir movie.<br />

Last updated 8/26/2011<br />

224

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!