Blender > Part 001 - "Real Time" Keyboard Control of objects



For us to understand how we can use blender to control our real life robots we have to know a little more about

Blenders Game Logic it is able to control  3D objects in "Real - Time" .


In this example we will use the Keyboard as a means of controlling a cube in "Real-Time" in the Game Logic Gui.

First select the "Game Logic" Gui

This will bring up 3 selections.

  1. Sensor
  2. Controller 
  3. Actuator

1. Select the "Add Sensor" pull down and select "Keyboard" sensor.


Hover of the "Key:" box and just press the key you wish to use as your actuator ... In our case "A"


2. On the Controller selection on the "Add Controller" selection choose "AND"

This will ensure that the command is always activated.... (it is possible to combine multiple sensors together and apply various logic combinations to suit)

(If you notice here ... this is where we will be adding "Python" code in a later walkthrough to come.)

It will then display so :-


3. The actuator selection is the last stage .... choose "Motion" here as we want to Move the Cube.


This brings up the motion selections....where you can set up the type and motion increments.


Using your mouse "link" the three modules together to form your sensor>controller>actuator links (marked red below)

Also type into the far right (red circle) "-0.10" in the Loc: field, this will be your offset increment .... each time the key A is pressed the box will travel -0.1 blender units on the x axis.


Now that the commands have been set up all you need to do now is fire up the "Game-Engine"

Hover over your object screnn and .......Press "P"


This enables the game control gui escape at any time press your escape key "Esc"

Press the "A" key and the cube should zip off to the left on the x axis.


Now all you need to do is the same for the other 3 directions to get  xy control of the cube.

In my case I linked the "R" key to a "Motion" actuator and typed in 0.1 into the Rot. field

I have included a video above to show the process an results.Its worth noting here that instead of keyboard control you could also use your mouse instead to control the cube.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
GroG's picture

Thanks for this excellent

Thanks for this excellent tutorial Gareth !

Funny, after watching the video the first question I had  was how to link Python to those inputs .. will have to wait for next tutorial ;)

Your making the "BEAST" of the program Blender approachable ...

Gareth's picture

In Blender there are at least 4 ways I know.....

In Blender there are at least 4 ways I know of to control things in "Real Time".

The method above is the "Basic Entry" and is easiest way to get things responding to keyboards and mice actions.

The other methods are  running Python scripts in "scripting mode" , running Python scripts in "Game Logic mode" and running scripts can i put it ... "Game Engine mode" ..... all are same/same but different ie. there are subtle Traps awaiting for us newbies......