Custom logic bricks?


I’m giving a course on quick game prototyping at the Université de Montréal and I use Blender as a tool to introduce the students to 3d game prototypes. I like it because we can quickly get something done with the physics and logic bricks without having to code anything, specially since the Python integration is a bit awkward for beginners.

Problem is, some very elementary actions are impossible to do with the current set: for example : a ‘Location Actuator’ that would position an object to a specific set of global coordinates, or a ‘Location Sensor’

Seeing what my students usually need, I’d like to introduce new bricks myself that would solve their problems.

I’m pretty familiar with the BGE python, but I don’t think it can be used to write new bricks. What would be the easiest way? I’m also familiar with C but not at all with the Blender source.



Oh, setting the location of an object should be easy just using a script you give to your students!
And telling to use Python controller :wink:
See e.g.

import bge
import mathutils
contr = bge.logic.getCurrentController()
owner = contr.owner
owner.localPosition =owner.localPosition + mathutils.V

Meaning you can set the local position easily! (ONCE at starttime or so)
I just use the (default) Cube, keyboard sensor connected to a python controller
the script above comes into the text area and klicking in the (free) field of the controller the name of the script can be chosen!
This problem seems to be solved like this …

Thanks for the reply even though I already know how to do this.

I was wondering if I could make ‘real’ logic bricks to offer a complete visual scripting experience. If logic bricks were simple to make, I’d be glad to make a few and share them.