Search Results

Wednesday, January 19, 2011

Introduction to the Blender Game Engine

Hi, there. As you may or may not already know, this is a blog about game design, and I'm going to help you, the reader, to create your very own PC game. One of the tools that I will be using is the Blender Game Engine, which is housed inside of the free, open-source Blender 3D modeling program.

Why use the Blender Game Engine (BGE)? Well, it comes packaged with a scene editor (the 3D modeler), as well as the top-notch Bullet physics engine. Also, it's very, very easy to get a game up and running, and it's also fairly simple to expand the engine to make a game with more complex gameplay using the Python programming language. Now, because this is a very basic tutorial and it's not really meant to delve into the more complex topics of the BGE, it'll just give a basic understanding of how the BGE works. The game logic executed in the BGE is made up of Logic Bricks. What is a Logic Brick?

This is a logic brick: A Logic Brick for use in the Blender Game Engine

In the Blender Game Engine, a Logic Brick is a portion of code (shaped like a rectangle) that the developer can customize to fit his needs and perform some sort of action. In the example to the right, this Keyboard logic brick is capable of reading information from the specified key - the Left Arrow. Logic Bricks are split into three types:
  • Sensors - Sensors sense physical data in the game engine or test data equalities
  • Actuators - Actuators perform actions on data or game objects - examples are motion, sound playing, and object creation
  • Controllers - Controllers test to see if the attached sensors equate as true, and if so, then they trigger the attached actuators. A controller could be And, Or, Nor, or other types of testing values.
As the example above shows, sensor logic bricks in particular have true and false pulse modes, which are the two buttons to the left of the 'Freq:' number box. The True and False pulse modes control how the sensor reads the input data specified. If you toggle those buttons, then they will send logic pulses to the controller depending on which button you press. By default, pressing the True button will send positive pulses as long as the sensor is true; without it on, the sensor will only send one positive pulse if the sensor evaluates as true (i.e. it won't loop. For example, if you set up an Always sensor with no True pulse, then it will run just once. Set True pulses, and it will consistently trigger). With the False pulse button, logic will, like the True pulse setting button, pass constantly as long as the sensor evaluates as being false; otherwise, the sensor will return false just once, when the sensor is false. The Frequency box controls how often the pulses fire. The default frames per second rate for the BGE is 60, so if you set the frequency to 10, the sensor will fire off 6 times a second. For more information on sensors, check out this very good page about using Blender Game Engine sensor logic bricks.

The basic idea of using the BGE would be to use sensors to read the data about the state of the game and to activate the actuators. For example, if you attach an "Always" sensor, through an "And" controller, and attach it to a Motion actuator, then the "Always" sensor will drive the Motion actuator - because there is no other sensor attached to the "And" controller, just the "Always" sensor will actuate it. For more info, check out the Wiki here.

For those who are more adept with programming, a Python controller is also present, which allows for using a Python script file to read the sensors and control the actuators. Python is a very powerful and useful programming language that allows for much more precision in the BGE than using logic bricks alone. With Python, most anything is possible to do with the BGE. Here's a link to a page featuring basic tutorials for using the BGE. Also, here's a link to download the Beta version of Blender 2.55 (with the BGE included, of course). Now, with a normal understanding of how the BGE works, making a game isn't going to be difficult at all. So, let's create a new game using the BGE. Since there are already tutorials for making basic games using the BGE, I was going to try making more complex ones. So, that's the idea behind using the BGE. Thanks for your time! - SolarLune


  1. Kudos to you for going out of your way to make all this, truly. It gets exhausting googling answers to questions as I encounter them; having a nice way to familiarize myself with the BGE and scripting with Python in the BGE all in one place has made my day. So from myself and all of those here who have used your tutorials but never commented, 1000x thank you.

  2. Oh, thanks, I appreciate that. I'll keep making them, and the tutorials will get more and more useful with time (I hope, LOL).

  3. I would also like to say thanks. Definitely bookmarking this site. Cheers!


    P.S. It's only possible to comment anonymously. It looks like the other options are broken. Maybe a missing captcha or something?

  4. Huh? I'll check that out - weird... Anyway, you're welcome! I'm glad that you like the site.

  5. Is there a missing link in the next-to-last paragraph? The last sentence just says "For more info, check out"... and then cuts off.

  6. After an exhausting search and ramble through the various and truly mind boggling amounts of game making tuts and web sites I have settled in and decided to try and get all the way through your BGE Python series and its primarily because you are very good at presenting your tutorials and I want desperately to learn how to use Python and especially with Blender. I really like Python a lot better than languages like C++, C+, C#, Lua, VBasic, Basic,,,ad nauseum, and I am determined to develop these cool open source tools. Thanks for your great web site.