[Dev] BGE Components Branch Created

There was some interest expressed in playing with my BGE components work. So, I started a branch so people could have easier access to the code and updates. The branch can be found here:


Some videos on components:

Some more information on components and how to make them:


Is not this mostly doable i python? A python add-on for blender and a ‘broker’ script for the bge. We would need a always sensor to call the broker but that could be added by the blender add-on.

Now I think this should be made in C, and it should even be possible to write components in C (and preferable as separate dynamic libs so You don’t need to build blender to write and use C components), and over time we hopefully get a good collection of ‘stock’ C components contributed by different people.

But it would be nice to be able to use it now! Best would be if it could detect the patches and use the python workaround only if needed.

Same thing with C components - it is good if they are detectable so a game can contain python components but look for C counterparts and use them if available.

I probably write a python broker so I can play with python components right away - an ad-on is less likely (i don’t mind that much setting stuff up manually). But how is components stored so it can be as compatible to the real thing as possible - and is there any ‘discover-ability’… If there is a api in the BGE for adding components from python I would want to mimic that as closely as possible to.

Is the source the only answer?

Components rulezzzz!

For the C thing there are already the possibility to write your own python module.
Maybe would be cool to give the possibility to call bge functions from the modules (a custom header [like python.h] to include?).

Btw how can i compile a branch? Must i download all the source. or is there a way to download only the changes and use the already downloaded source?( i’m on a notebook and i haven’t much space left :slight_smile: )

Python can already call C code well. You could write a C Python extension module that subclasses components, and it would look like any other Python component. However, you’d have to still go through the Py api and wouldn’t have direct access to the BGE C++ code.

Use svn switch.

I’m planing to write a python script that hooks up with a always actuator, collects all components, for the first run call there start() and then call there update() for every ‘tick’.

I can make something that works - at least the components them self should be able to be unaltered. That’s the most important thing - to be able to use components now and to be able to design functionality as components now for us in ‘stock’ BGE.

But it would be good to be so close as possible to the real thing.

How are the components tied to objects - some property? And the parameters - another property?

The components are classes. Is the one class per module, any naming scheme or registry going on? How do I know witch module to import for any given component?


I’ve been doing work with functions as sorts of ‘components’ - I almost got a mouselook function up (with optional arguments) without using any actuators or sensors apart from the Always sensor to drive it. The hang-up was on a problem where one of the axes of rotation got flipped when you looked at a particular angle.

I also got an Occlusion script that runs with optional arguments to work using several ray cast functions (it works well).


Compiled fine. Just a tip : the buttons for reload and delete the component are enlighted when the mouse pass over them, nor have an animation when pressed. It can be a bit confusing not see that you actually pressed them :slight_smile:

Components are really interesting, the only “negative” aspect is that are run each frame…
A partial solution can be to add in the update method

if controller["componentXX_counter"]<delay:
 controller["componentXX_counter"] = 0

where delay is the number of frame to wait between an execution and another

OK, after reading the source… It seams like making a .blend work both with the patched BGE and a python fall-back is not doable. I have to invent my own way to config and initiate components. But the components them self can hopefully be identical sans the base-class. That’s the most important part.

Even if our games need to be different with the current BGE, if we can design with components and design components that only take minor adjustment to work with future versions it is a good improvement.

I made the buttons more button-like. I’ll eventually get around for adjusting the pulse frequency like you currently can with sensors.

Her is a small proof of concept ‘fake’ components blend. I managed to use the example ThirdPerson component from the blog post unaltered.

The setup is completely manual… Not sure what route I want to go. Some ‘magic’ properties on the object is one way but that more or less mandate a blender ad-on to assist in setting the properties (but it could probably look quite as the real thing).


components.blend (452 KB)

Very nice idea well done!

Gets a bit tricky when there is a complex setup involved maybe have the component also display a line of text instructions that can be stored in the script.

An auto complete search system for the components would also be nice.

And some way to share resources would also be nice so you aren’t creating redundant resources.

Cant wait to see what this feature is capable of.

Seems some of the included components are not working properly ie camera.ThirdPerson “pPivot Name” should be “Pivot Name” and just plain cant get it functioning properly.

thought of another thing to add, if possible access to components or at least their variables from normal scripts.

That’s an interesting idea, though it may be possible already, as the components are integrated into the api.
Also, moguri, can you possibly add some more features:
Information about resource
Dynamic checkboxes (check a box to show more content)
I can understand that this is no walk in the park, but do let me know!

To access components at runtime, there is a components property on KX_GameObjects that use the BGE’s PySeq type. So, if there is a component named “Player” on some object, it could be accessed like so:

player_component = obj.components['Player']

And from there you have access to anything that’s exposed by the component (just like any other class in Python).

I’m not sure what you mean by “information about resource”. Are you talking about tooltips? As far as dynamic checkboxes, I’ll start thinking about it, but I’m not entirely sure how I’d want to go about it. The simple dictionary approach for arguments might be becoming to restrictive.

Thanks for the feedback!

Ok, i have asked before about tooltips, but i thought i’d mention on the thread incase anyone else wanted to ask.
About dynamic checkboxes, don’t worry, just a thought - i can see how it would defeat the purpose of a component.

Have you any idea when you’ll be able to implement tooltips?

Also, i have a problem with the windows components build - It doesn’t load components correctly, and frequently crashes when in full screen mode :confused:
Obviously, it’s not a final version, or in trunk, but still…
Thanks Moguri.
NB i also made a mouse show and uv scroll component, if anyone want’s em.
NNB - i might make a website for components (like a components market? :))

Is it possible to build a Blender 2.57+components for linux? Id like to have this patched blender for my Ubuntu box also. The components part looks promising and I really like it compared to having to link in scripts with controllers. Thanks for making your components work public.
and @ agoose77 thank you for the networking, I look forward to updates.

Thanks Argosse!
Maybe you could recommend some features that you’d like to see?
Also, with the components you have 2 options:
1)compile Blender yourself - modeterately difficult to newibe coders
2)download WINE and run the windows build http://graphicall.org/83

When I went to run in wine, I get some error about wine calling some unimplemented feature along the lines of windows vc90 or something. Lots of console output. If anyone would like to take a look ill make a text file after re-running.

And Ive compiled a couple things myself for my ubuntu, like an ipod compatible ffmpeg installation, a cpl emu servers I play with, so if you could point me in the direction of the source code Ill give it a try, that is if that code has a cmake or make list :slight_smile: haha, yea Im nooob