This sample shows mouse event scripts moving items within the scene.
Click on the image to download the sample.
| 
|
After importing the package, the scene contains two Cones, named Cone and Cone 1. Each of these cones act as rigid bodies in the scene. They also use the default floor plane collision graph (Floor Plane Collision Graph) which allows them to be influenced by gravity, yet not fall down infinitely. The script events are used to counteract against the gravity for these scene items. The floor plane collision graph looks like this:
To execute the scripts, click on the cones in the scene. The OnMouseClick even script for each cone will cause the cone to jump up into the air. Cone has the following code on its OnMouseClick event:
context.Velocity += new Vector3(0,5,0);
This adjust its velocity so that it jumps straight up into the air. It also has a similar script on its OnMouseWheel event: context.Velocity += new Vector3(0, 1.0f,0); This means you could could keep the Cone in the air by scrolling the mouse wheel with it selected.The second cone (Cone1) has this code on its OnMouseClick event: context.Velocity += new Vector3(0,10,0);
context.AngularVelocity += new Vector3(0,10,0);
This script also adjusts the velocity so that it jumps into the air, thought this time a little higher. It also adjusts the AngularVelocity so that it spins arouund the Y axis as it jumps into the air.