Simple Movement -- Blender 3D Game Engine





 


  
7
Add a Keyboard sensor for Jumping

Note:
The Keyboard Sensor must be named jump.  Can't be named Fred or Jump or anything else.  The python code looks for a keyboard sensor attached to the controller named jump.

Note:
For this tutorial, I'm using the Space Bar for jumping

Buttons Window menu >> Logic (F4)
Sensors Add
Keyboard Sensor
Name: jump
Key: Space


   
8
Add a Collision sensor for detecting the ground

Note:
The Collision Sensor must be named ground.  Can't be named Fred or Ground or anything else.  The python code looks for a keyboard sensor attached to the controller named ground.

Note:
To keep things simple, I'm attaching the Collision Sensor to the cube (ie the player).  A better solution is to create a thin collision pad (Object Type Sensor) under the player, parent it to the player and add the Collision Sensor to that.

Buttons Window menu >> Logic (F4)
Sensors Add
Collision Sensor
Name: ground


   
9
Add a Delay sensor for stopping the player

Note:
The Delay Sensor must be named stop.  Can't be named Fred or Stop or anything else.  The python code looks for a keyboard sensor attached to the controller named stop.

Note:
When the movement keys are released, the Servo Control linear speed is set to zero.  The Delay Sensor is activated, giving the Servo Control time to stop the player without sliding.  After 4 logic pulses, the Delay sensor turns off the Servo Control.

Buttons Window menu >> Logic (F4)
Sensors Add
Delay Sensor
Name: stop
Delay:  0   (stop immediately)
Dur:  4 (wait 4 logic pulses before turning off the servo control)



   




 
The Blender 3D and game engine tutorials were created as a series of step by step instructions and help you create computer games. Use the tutorials to make casual video games, First Person Shooter games, role playing games, racing simulation games and more. Use the tutorials as a self paced learning tool to model and program your own three-dimensional world and then play on your computer.