Professional Documents
Culture Documents
Blender25X CH22GameEngine
Blender25X CH22GameEngine
01-Game Engine
Return to Contents
Game Engine
Blender has the functionality to create interactive video games. The program
integrates real-time motion with physics and logic blocks allowing you to turn objects
into actors and move them around. This process also incorporates character animation
and allows interactive walkthroughs to be created where doors open and close.
The Game Engine is extensive in its application and it is not possible to cover all of
its intricacies in this document. You will have to research and experiment beyond the
scope of this very brief introduction to become proficient.
To get you started and wet your appetite for Gaming follow this very basic example.
At least it will show you how to open the door to the Game Engine.
Begin with the default Blender scene, delete the Cube and add a UV Sphere. Gaming
is a form of animation therefore as with all animation it is best to keep animated
objects with a low vertex count. To keep things simple the default UV Sphere will
suffice.
In the 3D Window Tab into edit mode with the Sphere
selected and grab ons single vertice on the side and make a
pointer as shown in the diagram. This will give an indicator
showing which direction you are pointing when moving
around. The Sphere with the pointer will be our Actor.
Vertices Grabbed and Moved
To form a Pointer
Press the P Key to see the Sphere descend and sit on the Plane.
It is time to tell Blender when and how we want our Actor to move.
In the Logic Editor Window you see the Logic Blocks, 'Sensors', 'Controllers' and
'Actuators'.
We will make some settings and make something happen to give you an idea how this
all works.
In the Sensors Logic Block click 'Add Sensor' and select 'Mouse'. Our mouse will be
the device we use to trigger the action. If you want to change your mind about this
click on the drop down where it says 'Mouse' and you can select something else. Let's
stick with Mouse.
Where it says 'Mouse Event' in the Sensor panel you select what part of the mouse
will be responsible for the trigger. Click 'Left Button' to see options but stick with
'Left button'.
In the Controller Logic Block click 'Add Controller' and select 'And'. Why? will have
to be explained later.
In the Actuator Logic Block click 'Add Actuator' and select 'Motion'. Motion because
we want our Actor to do some moving about. Leave the Motion type as 'Simple
Motion'. Its not time to go complicated.
In the Motion type there are two slots: Loc (Location) and Rot (Rotation) with x, y
and z values. x, y and z are the axis and the value will give the speed of the action.
Enter 'Loc' y:0.20 which means move along the y axis at speed 0.20. Note this is in
the positive y direction. To move in the opposite direction enter -0.20.
The last step for now is to connect the Logic Blocks. Click on the little black dot at
the RHS of 'Sensor and drag over to the little circle on 'Controller. Do the same
between 'Controller' and 'Actuator'.
Connections
Time for a test run. Put your mouse in the 3D Window and press 'P Key' (Play the
game). Give your mouse LMB a click. Just a click. You will see the Sphere in play
mode move. It may not be in the direction of the pointy bit on the Sphere but that can
be adjusted. If you hold LMB down the Sphere will continue moving and fall off the
side of the Plane and disappear into infinity. Press 'Esc' to end the game.
We will add a few more controls.
Adding controls ( Logic Blocks ) soon fills up the Logic Editor Window so to save
space you can click on the little triangles at the upper LHS of the panels and collapse
them. Click again to expand
Add more Sensor,s Controllers and Actuators as shown below taking particular
attention to the values in th Motion Actuators. Do not forget to connect them
together.
Motion Actuator Collapsed
0.20
Left button
Right Button
0.15
Middle Button
With the controls set as show above you can drive the Actor around the Plane. Play
with the Mouse buttons and you will soon get the hang of it. Note the Sphere only
rotates in one direction. You can add another set of controls to rotate in the opposite
direction. Maybe change the Mouse sensor to Keyboard and use the A an S keys for
rotation. You could change all the Sensor controls to Keyboard and use a pattern of
keys.
The foregoing is about as simple as it gets so its over to you to research and
experiment.