11.
Add Code to Rotate.py: Stop
the cube when the keyboad sensor Off (C key) is pressed
Note:
A motion
actuator is like a light bulb. Turn it on and it will stay on
until it is turned off.
Note:
The
PythonController Module function deactivate is used to turn off an actuator.
Add the code
# Run indented code on when On (C
key) is pressed
if off.positive == True:
#
turn the motion actuator off
controller.deactivate(spin)
12.
Insert
Rotate.py in the Python Controller
Note:
Blender
will automatically erase any script that hasn't been opened/created in
Text Editor.
Buttons Window menu >> Logic (F4)
Controllers Add:
Python
Script: Rotate.py
13.
Start the game engine.
Press X key
to rotate cube. Press C key to stop rotating cube.
Note:
If
you want to you can replace line 29:
if
off.positive == True:
with
if on.positive
== False:
If you do that, pressing the X
key will rotate the cube. Releasing the X key will stop rotating
the cube
User Preference menu >> Game >> Start Game
or
P key
X key to rotate
C key to stop
The Blender 3D and Blender 3D game engine tutorials were created as a series of step by step instructions to help you create computer games. Casual video games, First Person Shooter, role playing games, racing simulations and more. Use the Blender 3D tutorials to model and program your own three-dimensional world and then play on your computer.