Blender

Logic Action

Using the keyboard to move objects about (eg. Gaming)

 

Blender can be used to create 'game' type movement.

In this tutorial you will be shown how to move a object, the basic cube, in game type fashion using the up and down arrow.

 

1. Select the object you wish to control, in this example the basic cube.

2. Change to Camera View (num 0)

 

3. Click the Logic button

 

4. You are now going to Add "Sensor" "Controllers" and "Actuators"

Click the Add button on each

 

5. Now we will create movement for when the Up arrow is pressed.

Click the 'Always' button and choose 'Keyboard'

 

6. Now click on the blank 'Key code' button then press the Up Arrow on the keyboard

then press the Up Arrow on the keyboard

 

7. The next thing is to connect the 'Sensor' to the 'Controller' to the 'Actuator'

Click your mouse on the small green dot to the right of the 'Sensor' panel and drag a line to the small green dot on the left of the'Controllers' panel.
Do the same from the green dot on the right of the 'Controllers' panel to the dot on the left of the 'Actuators' panel

 

8. Now to move the object for each time the keyboard key is pressed. Each of the columns represent X, Y, Z axis.
We want to more the location of the object UP along the Z axis and we will move it 0.2 units for each key press.

Change the 'dLoc' on the Z axis to 2.00

 

9. Now to test it.

Press the 'P' key on the keyboard and
Try presssing the Up arrow your object should move up the screen

Press 'ESC' to return.

 

 

10. Now lets add down arrow movement.

First minimize each of the "Sensor" "Controllers" and "Actuators" by clicking the small yellow arrow on the right of each.

 

11. You are now going to Add a new "Sensor" "Controllers" and "Actuators"
Click the Add button on each

 

12, Follow steps 5, 6 & 7 above but use the down arrow on the keyboard in step 6

 

13. Set the 'dLoc' on the Z axis to -0.2 (it is minus because the object is moving down )

 

14. Now to test it.

Press the 'P' key on the keyboard and
Try presssing the Up and down arrow your object should move up& down the screen

Press 'ESC' to return.

 

15. Now to add another 'Sensor' this time use the 'R' key to rotate the object on the X-axis

follow steps 4, 5, 6, 7 for step 6 press the 'R' key

 

16. In the Actuator panel set the 'dRot' on the X-axix to 0.1

 

17.Now to test it.

Press the 'P' key on the keyboard and
Try presssing the Up and down arrow your object should move up& down the screen
Press 'R' the object should rotate.
Notice when you press the Up & Down keys the object does not always move up and down, This is because you have rotated the z-axis

Press 'ESC' to return.

 

 

Creating a Standalone RUN TIME

(ie. you don't need Blender to play)

1. Be sure to Save your Blender project

2. Pack the data. from the File menu choose Pack Data

3. Save as a Runtime , File menu, Save Runtime be sure to add .exe as the extension to the name.

 

4. You may need to have the following .DLL files in the same folder as your EXE

PthreadVC2.dll, python24.dll, SDLl.dll
You can find these three files in the Blender folder on your hadrdrive

 

 

Updated January 24, 2008