Even the blockbuster movie 2012 used the Physic Engine Blender is using: Bullit. In this tutorial we will discover some basics of the Physics and Game Engine possibilities within Blender, and make a small game where we can demolish a brick tower. It’s pretty addictive to destroy this tower with a small ball, using the arrow keys on your keyboard. This tutorial is made using blender 2.49 (32bit). Blender is an open source 3d-editor which can be downloaded from blender.org
Images will enlarge by clicking them. Hotkeys are given in order, so (S, Z, 20) means that you have to hit S first, then Z and at last 20. Hotkeys are particularly handy in Blender, this allows you to have one hand on the mouse and one on the keyboard and improve workflow.
Open a new scene and erase everything (hotkeys: A, X, ).
Add a plane (Shift + A, Add > Mesh> Plane, ) and scale it 20 times (S, 20) [x] Now switch to edit mode (Tab) and select the whole plane object (A). Extrude in Z-direction all 4 the edges, 3 blender units (Hotkeys: E, Only edges, Z, 3).
Now turn back into Oject Mode (Tab). Add a cube (Shift + A, Add > Mesh > Cube). Scale it in the X direction 0.500 (S, X, 0.5), the y-direction 0.250 (S, Y, 0.250) and the z-direction 0.250 (S, Z, 0.250). Grab it in the Z-direction 0.250 up (G, Z, 0.250). You should have something like this:
Also add a Hemi Lamp (Shift + A > Lamp > Hemi), set it’s energy on 0.500 (F5, in the Lamp Panel), and move it up 45 in Z-direction. (G, Z, 45)
Now we’ll add some physics! Go to the Logic Panel (F4), while having the transformed cube selected. Make it a rigid body. This makes it a body that reacts on gravity, can rotate and translate. There are several settings like rotation damping (which influences the rolling/damping friction), mass, etc. Make Damping 0.02 and RotDamp 0.18. Also hit the Bounds button and make sure box is selected in here (so that the object has box bounds):
Now that we set up the physical settings for one brick, we have to duplicate them. The physical settings will be duplicated as well. Duplicate (Shift + D) and arrange the bricks (grab, rotate in x and y direction) so that they form a nice square, as shown below:
Now add another layer of bricks on this first layer. Select one brick and duplicate it, and move it 0.500 up (G, Z, 0.500), and make another ‘square’ on top, as is down in the picture below:
Finaly select those two bricklayers and duplicate them about seven times. Each time you duplicate one bricklayer, move it up 1 (G, Z, 1). Finally you should finish with a small brick tower:
The final step is to add a ball, which we can control and move the bricks away with. First add a sphere (Shift + A > Mesh > UVSphere (32 segments & rings, radius 0.3). Move it somewhat to the left (G, X, -15) and up (G, Z, 0.5). Now go to the logic panel. Make the sphere a rigid body and setmass to 10.00, damp to 0.02 and rotdamp to 0.18.
Now you can add sensors in the logic screen. The image below is pretty big, but covers all settings for moving the ball. Add a keyboard sensor, and in the Key field hit UpArrow. Add a controller and link the controller to the sensor. Now add an actuator, and link the controller to the actuator as well. We want to actuator to be a motion actuator. In the actuator, we want to set up the force that is working on the ball. I decided that up arrow will result in a force of 100 in the x-direction (the first box, the second is y and the third z). Also deselect the L in that row, so that the motion will not be local (otherwhise you will get very strange movements). Do the same for the left, right and down arrow. For me, the down arrow was -100 in x direction, the right arrow -100 in y-direction and the left arrow +100 in y-direction.
You might add other controls as well, if you want, for example in the z-direction. I expanded all setting panels in the screenshot, but you can can collapse them also, by clicking on the little orange triangle.
If you set up everything right, you can now start playing the game! Choose a good angle in the 3D-view so that you can see whole the scene, hit Game > Start Game (P), and enjoy your brick tower demolishing!