Design – Blender Game Engine is Awesome!

One of the things that I really liked when I started working with SuperTuxKart to create my game Loop Dipole and the Chaoties, was that STK uses Blender for all of its level and character (kart) development. Blender was a program I had heard about, “something, something, it’s pretty popular, etc.” and I was pretty certain I’d installed it a couple times over the years. I figured using Blender would be great, because it’s a whole 3D modeling tool itself, not just part of another project (like a map maker for STK), so it probably has some documentation and tutorials.

It turns out that the Internet is bursting at the seams with tutorials for Blender!

Yeah, in my effort to learn enough about Blender to make a level for STK, where I could test movement and my art style, I discovered that countless thousands of kind people have posted written and video tutorials for Blender. Topics range from helping the complete beginner overcome the fairly steep learning curve (which is mostly learning and getting used to the wacky UI and controls) to how to use the built in game engine. Built in game engine? Interesting.

After putting together a functional, empty level and a custom character model for testing in SuperTuxKart, I got to work on making the character move the way I would like. STK 0.8.1 uses the Irrlicht Engine for graphics and, from what I can tell, for implementing at least some of character movement as well. I read about how to use the Irrlicht libraries and was a little bit confused by how they were put to use in STK. None the less, I managed to bind firing abilities to the right and left mouse buttons, but I wasn’t having much luck with figuring out the STK way to make Irrlicht “mouse look” work. Given that my character will be little sci-fi looking aircraft, I also wanted it to bank (lean) when turning. Banking wasn’t too hard to get working (neither was changing the reverse camera to be a secondary forward camera btw), but I ran into a strange issue that I wasn’t able to solve. The code for gently returning the character to horizontal after banking in a turn would only work while the turn key was held down – remove your finger from the key and the character would slap down to the ground instantly. Clearly not a big deal for STK, where karts never lean far anyhow, but it looked awful in my usage. I chatted with one of the STK main programmers about it and we (I am pretty sure) agreed that the code block handling the leaning looked like it should work as expected, but it… didn’t work as expected (incidentally, it’s STK stock code, not something I changed).

I spent an evening rewriting the leaning code for STK, in the least efficient, but most explicit way I could think of, and same thing happened… release the turn key BAM! character slams to the ground instantly. Keep your finger on the turn key and let off the throttle, character gently returns to the ground as it’s supposed to. *sigh* Mouse look kinda sort of works, but I can’t seem to get the mouse to stay inside the game window, because the Irrlicht way of doing things doesn’t seem to… fit into the STK framework (and I don’t know enough about C++ to jam it in there)… Mouse buttons only work because I routed their input to keyboard keys… “Lucy, you got some ‘splain’n to do!”, I says to the monitor and head to bed…

It was at this point when I thought I would take a break from the C++ for a bit and fart around with Blender. You know, I’d have to learn more about Blender anyhow, right? 🙂 After a couple days of watching videos, reading, making some stuff, and playing around with blend files from other people, it occurred to me that maybe it would be a good idea to look a little closer at the Blender Game Engine. Like, what can it really DO anyhow?

Turns out it can do this,

and this,

and this,

and even this!

Needless to say, I was impressed. These are awesome projects!

So getting back to what makes me happy… with Blender we have a single tool that is amazing for 3D rendering and animation, yet it also has a Python scripting, a visual logic builder, and the Bullet physics engine. All of this in a single, open source tool that runs on Linux, Windows, MacOSX, and other operating systems…

I would be stupid not to look into using Blender Game Engine to make my game!

So I spent a week or so playing with its various features, working out the basics of how a I could create the quasi driving game mechanics that I would like. Luckily for me, the BGE was initially created as a car racing demo so it already has detailed C++ level functions for the complex handling of motion. These features can be accessed using Python scripting and conveniently the vehicle demo lays out basics plainly.

While there are other ways to control a character than using the rigid body / vehicle class method, such as using the built in “character” preset, ultimately for my purposes the vehicle class fits my needs best. I particularly appreciate the camera setup in the vehicle demo – lots of great options there! I did create a nifty sci-fi UFO type movement system in one of my testing files, complete with a weird ass chase camera and mouse look, which I liked, but I wasn’t able to make the character rotate to match the terrain (need to learn the syntax a lot better to use rays!) and honestly, the vehicle physics felt more fun.

So…

Loop Dipole and the Chaoties is now a Blender Game Engine project! You can follow it on GitHub here.

Using BGE should be a lot more efficient and ultimately more enjoyable than using modding SuperTuxKart. I won’t have to spend hours removing content and features that I won’t need (as would be the case with STK) and I have the benefit of knowing that whatever works in Blender when making the game will… “just work” in the final game too! How’s that for some lovely rocket magic, eh?

Ps. I’ll post a zip file of my SuperTuxKart code to my One Drive later, as I restarted the Github repo. Have a look in there for some of my Blender testing levels and other stuff as well!

Advertisements