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

on Follow_Update(me)<br />

vTransform = pParent.getWorldTransform()<br />

vPosition = vTransform.position<br />

vZAxis = vTransform.zAxis<br />

vRayData = p3DMember.modelsUnderRay(vPosition, vZAxis, pRayInfo)<br />

if not vRayData.count then<br />

vDistance = pMaxDistance<br />

else<br />

vImpactData = vRayData[1]<br />

vDistance = vImpactData.distance + pRadius<br />

vDistance = min(vDistance, pMaxDistance)<br />

end if<br />

pCamera.transform = pTransform.duplicate()<br />

pCamera.translate(vZAxis * vDistance, #world)<br />

end Follow_Update<br />

Note: You can use a third-person camera to follow any character, including characters that are not controlled by the user.<br />

The camera will follow whichever node you set it to follow. You will simply have to call the Follow_Update() handler<br />

each time the nod moves.<br />

MiniMap<br />

You can use a secondary camera to create a minimap of your 3D world. If you place a camera directly overhead, facing<br />

downwards, it will automatically create a bird's view of the world. You can work with this view in several different ways.<br />

For example:<br />

As an insert in the main 3D sprite.<br />

As an alternative view in the main 3D sprite, that the user can switch to.<br />

As the main view in a second 3D sprite that displays the same 3D world.<br />

Note: Using a camera to display a minimap as an insert creates an opaque area within the main sprite. You may prefer<br />

to use a semi-transparent overlay to create your map. See “Overlays and backdrops” on page 47 for more information.<br />

You can also choose between different ways of handling the movements of the minimap camera with respect to the<br />

user's avatar:<br />

The minimap camera can be a child of the avatar. In this case, the avatar will always appear in the center of the<br />

minimap, and the view in the minimap will always rotate so that the avatar's view looking towards the top of the map.<br />

The minimap camera may be in a fixed position. In this case, the avatar will move around the visible space. You<br />

may need an additional way of indicating the direction in which the avatar is facing.<br />

To see an example of a minimap created as an insert with the camera in a fixed position, download the movie<br />

MiniMap.dir and launch it. This demo allows you to click inside the minimap to move the avatar to a new position.<br />

Last updated 8/26/2011<br />

233

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

Saved successfully!

Ooh no, something went wrong!