Director Tutorials


3D Collision Detection Demo

Movie file - CollsionDemo.dir
In the movie, a number of behaviors are attached to the Shockwave 3D sprite (sprite 1) to make it work. They are as follows:

Reset World - Chrome Behavior
This behavior resets the 3D scene to its starting position as soon as the sprite is first initiated. It is important for all Shockwave 3D use. It should be at position 1 of the list of behaviors attached to the sprite.

Attach Camera to Model - Chrome Behavior
This creates a parent child relationship with the camera and a model. A Model that is selected becomes the parent, the camera, the child. A child object will always follow any changes to the parent. If the parent is moved forward, so will the child. This behavior is important for grouping a 'character' type model to a camera. There is another behavior in the Chrome library to do the reverse - 'Attach Model to Camera' and 'Attach Model' which will attach one model to another.

Model Control - Chrome behavior
Controls the movement of a model (using A, S, D, W keys).

Collision - Dean's behavior
Sets up movement and collision detection. If you use this, you won't need the 'Model Control' behavior.

In the cameraMove handler in the 'collision’ script', I set the rotation to be 1 degree and the forward and back units to be 30. You can change this for your world. Every shockwave 3D may have a different scale and so you may want to move a greater or lesser amount. Play the movie, use the arrow keys, and then change the values to suit the speed you want.

The pCamera.worldPosition.z is set to 1286.8694. This is to keep the z position (vertical height) the same all the time.

I found this value by going to the message window and typing:
p3Dmember = sprite(1).member
pCamera =
put pCamera.worldPosition.z
Pressing enter after the above line output the following:
-- 1286.8694