Gamasutra: The Art & Business of Making Gamesspacer
View All     RSS
January 22, 2018
arrowPress Releases

If you enjoy reading this site, you might also want to check out these UBM Tech sites:


Using Blender in your game development projects

by Dragan Javorac on 07/12/13 09:29:00 am

The following blog post, unless otherwise noted, was written by a member of Gamasutra’s community.
The thoughts and opinions expressed are those of the writer and not Gamasutra or its parent company.


In this article I would like to talk about using Blender in your own game development hobby projects. Blender is a freeware 3d suite ( I’ve been using Blender since the beginning and during my forays into hobby game development I’ve been exploiting the python script feature in a myriad of ways. The python script feature is quite powerful to someone with a programming background. And that is what I would like to talk about in this article.

I’m currently doing some experiments with 2d games with pre rendered graphics. On any character I can have a multitude of animated actions(walk,attack,block,death the usual) and depending on my perspective (strait top down or Zelda top down) I might have up to 8 rotations as well.
Rendering all of these by hand is a chore and error prone. That’s where I looked into python scripting for automating this task. 


this was all done in Blender 2.6.x


First of  let me introduce you to the blender text editor and the python console:

texteditor and python console

The window on the left is blenders text editor and the window on the right is the python console.

The python console allows you to check out all the methods and properties on the data structures with its autocomplete(ctrl-space). This autocomplete feature can get you very far when experimenting:


if you've noticed that the text editor is very plain looking, you can turn on line numbers and code highlighting  to turn it into a more programmer orientated display:


You can do this by clicking the little buttons between the script dropdown and the run script button in the command bar.

Another thing is the system console, which you will want to turn on when you run & test your scripts. If something goes wrong the error will be printed there.

Click the help menu item in the (i) window pane (usually on the top/left of a default blender install) and then toggle system console as shown in the pictures below. That will open a dos like window.


A basic script example:

Most scripts start with the relevant imports like import bpy, which allows you to access the scene data and other functions.

When you have your imports you usually want to acces the data in the scene.That can be done by using:[0] or[‘Keyname’] to select a specific scene. To select the current scene use: bpy.context.scene


Lets do a simple script which renders a image.

You need to know that your render settings are per scene and you can access them via the render object on a scene object:

To render something you can call: bpy.ops.render.render(…)

for example to render a single image:

import bpy
scene = bpy.context.scene
scene.render.filepath = 'c:/tmp/helloworld'
scene.render.resolution_x = 200
scene.render.resolution_y = 200
scene.frame_current=  200
bpy.ops.render.render(animation=False, write_still=True)

To render multiple images:

import bpy
scene = bpy.context.scene
scene.render.filepath = 'c:/tmp/helloworld'
scene.render.resolution_x = 200
scene.render.resolution_y = 200
scene.frame_start=  0
scene.frame_end=  5

Running either of these scripts will render some images to the specified locations.


There you have it your first blender script, it's simple but by expanding it you can automate a lot of tasks. Which is usually worth the time invested in making the script

Custom properties:

One other thing I made use of, is another nice blender feature: the ability to create custom properties on objects. These properties are something which i use a lot in my exporters and my rendering scripts.


The properties are found in the properties window which is on the right of a typical blender screen. On the bottom of the properties window you will find a collapsed section called custom properties as shown here:


These properties can hold more than just a float. to use strings just type them in the value textfield when editing a property.

These custom properties can be accessed, added, removed and altered from the script API. Giving you a lot of customisation options.

Just use object.get(‘keyname’) to get the value. If the property doesn’t exist you’ll get a None object as a result.


These are the first steps and with a little bit more work you can easily transform blender into a level editor with a few scripts. Currently I have a couple of scripts for my 2d game: one which renders unique objects and one which creates a xml describing the level, it's objects and their custom properties.

Through these scripts i have a exporter which allowed me to visually create the tiles for my level and place monsters spawn points and more. just use some imagination and you can create a lot of usefull stuff in blender.

If you have no idea were to get started:
-visit the blender docs:

-Look at the scripts already packed with blender
-fiddel with the python console.

Related Jobs

Remedy Entertainment
Remedy Entertainment — Helsinki - Capital Area, Finland

Senior AI Programmer
Giant Enemy Crab
Giant Enemy Crab — Seattle, Washington, United States

Gameplay Engineer
Lucky Charm Games
Lucky Charm Games — Altadena, California, United States

Web Developer - Front End
Blackstorm — Mountain View, California, United States

Studio Game Engineer

Loading Comments

loader image