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 />

In SlideAlongWall.dir, the camera turns to face along a barrier after coming close to it<br />

Below you will find a handler similar to the one in the SlideAlongWall.dir movie. It accepts three parameters:<br />

aNode: a pointer to a node that may collide with a barrier<br />

aDirection: a vector pointing in the direction that aNode is attempting to travel<br />

aNormal: a vector pointing out from the barrier at right-angles to the point of collision<br />

The handler will turn aNode by 2 degrees, or until it is no longer facing towards the barrier. This handler is called once<br />

per frame, so the node will turn automatically until it is facing along the barrier. The node can then continue to travel<br />

parallel to the barrier.<br />

Note: If the node were touching the barrier but facing at exactly 90° to the normal, then it may remain stuck. By using a<br />

value just over 90.0°, you can be sure that the node will be able to move after it has completed its turn.<br />

on TurnAlongBarrier(aNode, aDirection, aNormal)<br />

vAngle = aDirection.angleBetween(-aNormal)<br />

if not vAngle then<br />

-- Let the user choose which way to turn<br />

exit<br />

end if<br />

vPosition = aNode.worldPosition<br />

vAxis = aDirection.cross(aNormal)<br />

vAngle = min(2, (90.001 - vAngle))<br />

aNode.rotate(vPosition, vAxis, vAngle, #world)<br />

end TurnAlongBarrier<br />

Note: If the user is controlling the rotation of the camera or avatar, then you will want to avoid applying an automatic<br />

rotation. The Steer and Slide Camera With Mouse behavior detects when the user is explicitly turning, and does not call<br />

the TurnAlongBarrier() handler when this occurs.<br />

Hugging Terrain<br />

In your 3D world the ground may not be flat. As the camera or avatar moves around, you will want it to remain at the<br />

same position with respect to the terrain beneath it.<br />

Last updated 8/26/2011<br />

238

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

Saved successfully!

Ooh no, something went wrong!