Blender for Robotics | Part 3 | Interfacing with the GameEngine


In the second part of this tutorial I presented how to rig a robot model in Blender. In this part I will show you how to make use of the Blender Game Engine (BGE) — and more importantly, how to control armatures/robot models in the GameEngine [1].

In order to complete this tutorial I assume you have little experience in C++ and Python programming as well as CMake and other build tools. Therefore, this tutorial will be as detailed as possible. As a first step I need to make sure you have set up your environment correctly (in terms of this HowTo).

Install Python 3.2.1

sudo mkdir -p /opt/blendertutorial
sudo chgrp -R $YOUR_USERNAME /opt/blendertutorial
sudo chmod -R g+w /opt/blendertutorial

cd /opt/blendertutorial
mkdir dependencies && cd dependencies
tar xvf Python-3.2.1.tar.bz2
cd Python-3.2.1
./configure --prefix=/opt/blendertutorial --without-pymalloc --with-wide-unicode --enable-shared
make -j2
make install

Install Blender 2.63a

Now, install Blender 2.63a, fast version below:

sudo apt-get update; sudo apt-get install subversion build-essential gettext \
libxi-dev libsndfile1-dev \
libpng12-dev libjpeg-dev libfftw3-dev \
libopenexr-dev libopenjpeg-dev \
libopenal-dev libalut-dev libvorbis-dev \
libglu1-mesa-dev libsdl1.2-dev libfreetype6-dev \
libtiff4-dev libavdevice-dev cmake libboost-all-dev \
libavformat-dev libavutil-dev libavcodec-dev libjack-dev \
libswscale-dev libx264-dev libmp3lame-dev python3.2-dev git \
libspnav-dev libtheora-dev libjack-dev libglew1.6-dev curl

cd /opt/blendertutorial/dependencies
mkdir blender && cd blender
tar xvvf blender-2.63a.tar.gz
cd blender-2.63a
mkdir build && cd build
make -j2 && make install
cd /opt/blendertutorial/bin
ln -s ../dependencies/blender/blender-2.63a/build/bin/blender blender
ln -s ../dependencies/blender/blender-2.63a/build/bin/blenderplayer blenderplayer

Test your installation! Execute: /opt/blendertutorial/bin/blender. You should see something like that:

If everything worked out as expected, you may open the first blend file provided along with this tutorial. You will find a "robot" in there. Well, it is not exactly the most advanced robot, this is not about modelling, but programming. In the last tutorial you learned how to rig a robot model, and how to apply a kinematic chain. Now you will learn how to make use of that in the BGE. The robot consists of a torso and two arms, each with 3 joints. IK chains are applied on both arms without any angular limitations (3 DoF). The IK chains are driven by so called empty_objects (see: orange cross in the figure below), which means: If you move an empty_object, the robots arm tries to approximate the 3D position (no orientation) of the emtpy_object (target_left & target_right). Please play around with the provided blend file.

The Game Engine

To view the model in the BGE, open the tutorial file and place your mouse cursor over the 3D window and press "p" — to exit the Game Engine press "ESC". In the first video you will learn how to record and replay actions in the BGE.

Here's the video, you may watch it first to actually see what's about to happen. The necessary steps will be described below. There's a complete solution of this tutorial attached below, but you should try this out on your own — using the first file.

Okay, in the opened blend file select an empty_object (right mouse button) and place it somewhere in the 3D space. Press "i". A new menu opens, select LocRotScale.

What this actually does, is to add a key frame [2] for the selected object with regard to location, rotation and scale of the object. At this point it is important to set the position of the timeline marker (bottom window, green lines) to another time step if you want to add further key frames.

After you added several key frames for all objects you may want to animate, you can skip through the key frames in the timeline window to actually see whats going on. Alternatively, you can place the mouse cursor over the 3D window and press ''Alt+a" which plays the whole animation from the beginning to the end in a loop.

If you're happy with your animation(s) you can trigger them in the BGE. How to do that? First of all select the Armature in Object Mode. With the Armature selected, open the Game Logic Panel [3]. You can open the Logic Panel by selecting the "Joystick" option from the list in the bottom left corner (check Video 2:05 minutes).

It is extremely important to add an "Always" Sensor, connected to an "Or" Controller which connects to an "Armature" Actuator. If you don't do this, you won't see any movements of the Armature in the Game Engine (check the video 1:50 minutes). Another important fact to mention here is, that you add Controllers, Actuators and Sensors to each object you want to animate, trigger or move in the BGE. In the beginning, at least from my point of view, this was confusing, because as soon as you select another object, all the stuff in the Logic Panel is gone (not really, but one might think so).

In the following step we will add a "Keyboard" Sensor connected to a "Or" Controller, connected to an "Action" Actuator, which plays the previously recorded animations (check video 2:15 minutes). You need to do that for both empty objects. The key "G" triggers both actions. You connect the logic bricks by dragging the mouse while holding the left mouse button pressed.

As you can see in the video at 3:42 minutes it is also important to set the animation length to the desired/correct value, which is 65 frames in this example.

Well, now you are done. Place the mouse cursor over the 3D window, press "p" and the Game Engine will come up. Now press "g" and you will see the previously recorded actions. That's pretty cool, huh? All steps which were previously explained are assembled in this file.

As a "plus" I have yet another blend file where you can control the left arm using you keyboard keys "Left Arrow" and "Right Arrow" — but have you look yourself. Remember, press "p" and have fun.


This tutorial is partially based on CC content, therefore I decided to publish my content under CC too.


In the second part of this tutorial I presented how to rig a robot model in Blender. In this part I will show you how to make use of the Blender Game Engine (BGE) — and more importantly, how to control armatures/robot models in the GameEngine [1].
BFR_tutorial_warp1337_GE_1.zip74.82 KB
BFR_tutorial_warp1337_GE_2_actions.zip77.93 KB
BFR_tutorial_warp1337_GE_2_keycontrol.zip96.75 KB


Great tutorial

Thanks man. Helped me alot.

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code>
  • Lines and paragraphs break automatically.

More information about formatting options

This question is for testing whether you are a human visitor and to prevent automated spam submissions.
14 + 3 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.