Erik Pukinskis

My Blender Game Engine Introduction

The following are just random notes I took while trying to figure out the Blender Game Engine. Hopefully I'll turn them into a tutorial some day, but for now they are just rough notes.

Followed the first few steps of this tutorial, to get used to the interface, manipulating objects and such:

  http://en.wikibooks.org/wiki/Blender_3D:_Noob_to_Pro

Followed much of this tutorial, to get the basics of the game engine:

  http://www.ingiebee.com/tutorials/Blender%202%20tutorial%20The%20Blender%20Game%20Engine.htm

This tutorial helped me understand the basics of .py scripts in Blender

  http://jmsoler.free.fr/didacticiel/blender/tutor/python_script00_en.htm

Looked at the source code for this, which gave me confidence that you can do real code stuff.

  http://ash.webpark.sk/multiplayer_eng.htm

This appears to be the Blender API reference:

  http://download.blender.org/documentation/NaN_docs/Manual2.0/PythonScripting.html

Or maybe this is:

  http://www.blender.org/modules/documentation/228PythonDoc/Blender-module.html

This is really interesting, this guy has some serious interactivity here, it seems:

  http://blenderartists.org/forum/showthread?t=46100

Still trying to figure out the basics of how to get scripts called at the right time.

This would've been great to read earlier on:

  http://theboomshelter.com/hss.html

... but it's not working! argh!!! I am getting errors like "unable to find requested actuator", and Google can't tell me why.

... ah, I'm a flippin' idiot, and I didn't follow directions. It's funny, I thought the explanation was "API instability". But it was just "me=flippin idiot".

This list of samples/tutorials seems key:

  http://blenderartists.org/forum/showthread?t=11430

Things that are hugely important:

 - You have to connect the sensors to the actuators, otherwise the controller won't see them.
 - You need to name the sensors and actuators.  Duh.

This is a useful Python reference:

  http://docs.python.org/lib/lib.html

The GameLogic API is listed separately from the Blender Python docs:

  http://www.blender.org/documentation/pydoc_gameengine/PyDoc-Gameengine-2.34/index.html

You don't appear to be able to set booleans by saying something like

  my_bool = False

You have to say

  my_bool = 0

Why? Who knows?

How do you print formatted strings in python? They have a special operator for that, instead of printf:

  http://www.wellho.net/mouth/496_Python-printf.html

The proper way to do global variables in Blender is this:

  GameLogic.foo = "whatever"

This tutorial was useful to read through. It gave me a better sense of the game engine, although I don't think I

actually used any code from it:

  http://otothegardener.free.fr/tutorials/Flipper/flipper.htm

Do do drag and drop, it's nice to see the cursor:

  import Rasterizer
  Rasterizer.showMouse(1)

Finally getting a scent on how to do globals:

  http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/59892

This is how to do globals in the Blender Game Engine. Put the following somewhere in a python controller that is connected to an "Always" sensor:

  try:
      GameLogic.yourvar
  except AttributeError:
      GameLogic.yourvar = None

Now you can use GameLogic.yourvar wherever you like.

I don't know exactly what "Rigid Bodies" and "Anisotropic Friction" mean... but for the purposes of just boxes being pushed around, it seems to work better with them both off.

At some point along the way I learned that dictionaries are just lists. These helped:

  http://diveintopython.org/file_handling/for_loops.html#dictionaryiter.example
  http://diveintopython.org/native_data_types/tuples.html

More on globals and locals:

  http://diveintopython.org/html_processing/locals_and_globals.html

I figured out how to get and set the position and orientation of objects here:

  http://www.blender3d.org/documentation/pydoc_gameengine/PyDoc-T2-Gameengine-2.34/KX_GameObject.KX_GameObject-class.html

This hotkey list told me that to join two objects (so I can weld them together) I use CTRL+J. To weld (merge) vertices I go into edit mode (TAB), select the two vertices (by right clicking, and then SHIFT+right clicking), and then hit ALT+M, and have them merge at center.

  http://en.wikibooks.org/wiki/Blender_3D:_Noob_to_Pro/Hot_Keys

This is a wierd one: I found that sometimes the objects were REALLY bouncy in the physics simulation. The solution to this is to give them a material. Click the Shading tab (the shaded sphere) on the buttons bar, and then click "Add New" under "Material".

To scale an object along only one axis, you just enter scale mode (select the object, and hit S) and then hit x, y, or z, and you'll scale only along that axis. I tried looking under "constraints" for this, but that wasn't the right term.

When rotating (by selecting an object and pressing R), hold down the CTRL key to get it to snap to 5 degree increments.

Do you want to position an object in a specific place? Press the N key while your mouse is over a 3D view.

To get one object to line up precisely with another, Click the Object button (looks like 3 axes) in the buttons panel, and add a "Copy Location" constraint. Put in the name of the object to align to, and choose the axes you want to align.

I really don't understand the bounding boxes. I have been trying different settings randomly, with seemingly random outcomes. Sometimes when I pick up different copies of the same box, they seem to have vastly different behaviors. I imagine this is a result of subtle differences in z-position and rotation that are having a big effect on the physics simulation. Not sure. Very confusing.

You access the boolean tools by hitting W.


 
This page was last updated May 24, 2006 at 8:20pm.