From BlenderWiki

Jump to: navigation, search
Note: This is an archived version of the Blender Developer Wiki. The current and active wiki is available on wiki.blender.org.

BGE Collision API

I don't yet know whether to use an event list or callbacks.

CollisionEvent objects

Properties:

  • location
  • material
  • object

(These I would like to include)

  • normal
  • force

CollisionEvent list

Stored on KX_GameObjects. For each collision, two events are created and one is stored on each KX_GameObject in the collision.

Example:

for ce in obj.collisions:
	if ce.name == "Bomb":
		obj.endObject()

Collision callbacks

Collision callbacks are registered on KX_GameObjects. The callback functions take a KX_GameObject and a CollisionEvent object and do not return anything.

Example:

def col_bomb(self, ce):
	if ce.object.name == "Bomb":
		self.endObject()

obj.register(col_bomb)