| www.blender.nl this document is online at http://www.blender.nl/showitem.php?id=14 |
| |||||||||
|
![]() |
|
![]() |
|
![]() |
Press to
start the real-time simulation. It just sits there - nothing happens! No
wonder, since we have not defined any physics or events yet. Let's do that
now. |
| Dynamics |
Stop the simulation
with . Select
your character and go to the Real-time buttons (press ![]() ). On the
far left you'll see a button labeled 'Actor'. An actor is not necessarily the main character in a game. An example of an actor can be an enemy that follows you around the game. |
|
![]() |
Rotate your view a bit
(the top view will not show this effect properly) and press .
Your character falls to the floor. |
| Forces and Materials |
| Now let's work on the
physics a bit more. First of all there is a global parameter for gravity
in the World Buttons window. Add new world settings; a new slider called
'Grav' is now availabe. This is a constant for your world; all the Dynamic
objects are affected by it. The standard value is 9.8, which results in a
natural gravity-like acceleration of falling
objects. |
|
![]() |
| 1) Mass.
When applying a force, the mass determines the acceleration that an object gets. Higher mass results in a smaller acceleration. When you have both large and small objects in your game that interact with each other, be sure to match their relative masses - this will add to the realism of your simulation. 2) Damp. Motion dampening. This is a friction force that always works on your object - both when it touches a floor and when it is free. A good way to describe it is 'air friction'. When an object has a Damp value, it will always slow down when there are no other forces working on it 3) RotDamp. Rotational dampening. Like the motion dampening, this affects an object's rotational speed. 4) Size. Blender's current physics engine uses spheres to represent your dynamic objects. This parameter represents the size of the sphere. The collision sphere is drawn as a dotted circle in the 3D window. In most cases, you should try to enclose your object in the collision sphere. If you don't, parts of your object will be able to stick through walls and other objects. |
|
![]() |
|
![]() |
Press and
watch your character fall down the different planes. Something still is
not right here: whenever it hits a plane, it immediately sticks to it and
starts to slide down. To fix this, we'll have to tweak the dynamic
material properties of the planes. |
|
![]() |
As the first test,
let's play a bit with the 'Restitut' value. This value determines how much
of the object's kinetic energy is returned to the object after it has a
collision. In other words: this value defines the 'bounciness' of your
material. Set it to one now. Select the plane directly underneath your
character and clear its rotation with ![]() to level it.
Press to play your
simulation. You would expect it to keep bouncing, wouldn't you? Wrong - remember the 'Damp' setting? The dampening slows down your sphere a little all the time. That is why it bounces less and less high. Select your character and set 'Damp' to zero. Press again and
watch it bounce ad infinitum. Take a look at this example: the planes have been placed to keep the ball bouncing around for quite a while:
|
| Reset the 'Damp' value
to 0.04 now. The next thing we are going to try is called 'Fh'. This is a
term that has been borrowed from physics where it means a force in the
vertical direction. It works the same in Blender, but here we also have to
define a region of influence. This region of influence is controlled by Fh
Dist. This value creates a 'cushion' around your object in which the Fh
force will be active. Try the following: set Fh Dist to and Fh Force to 0.4. Now select your character and go to the Real-timeButtons again. You have to click 'Do Fh' to enable Fh. Now play your game (clear the rotation of the top plane again before playing). Your character now hovers above the plane like it is floating on a magnetic field. The influence of the Fh force is linear with the distance to the object: it varies linearly from zero to Fh in the interval of Fh Dist. |
| The Fh Dist value is
also used for collision detection. As soon as another object enters the
'cushion', a collision is registered. What's more, the incoming object
gets the color of the object that it collides with. This allows for visual
debugging during playback. That was it for the basics of the game engine. The next step is to learn how to control your character. This is described in Controlling a Dynamic Object. |