Bullet Ghosts

Don't mind the mess!

We're currently in the process of migrating the Panda3D Manual to a new service. This is a temporary layout in the meantime.

Ghost objects are intangible objects. They do collide with other objects, but they won't create any collision response (forces etc.) from such collisions. Ghost objects keep track of all objects they collide with, and it is possible to query them for all objects they currently overlap with.

Ghost objects therefore can be used to implement a sensor, which detects the presence of any (or a particular) object within the sensor's shape. For example an automatic door which should open if the player is in front of the door, or an area which triggers some event if the player moves through the area.

Example for how to setup a ghost object:

from panda3d.bullet import BulletGhostNode
from panda3d.bullet import BulletBoxShape
shape = BulletBoxShape(Vec3(1, 1, 1))
ghost = BulletGhostNode('Ghost')
ghostNP = render.attachNewNode(ghost)
ghostNP.setPos(0, 0, 0)

Example for how to get overlapping objects:

def checkGhost(self, task):
  ghost = ghostNP.node()
  print ghost.getNumOverlappingNodes()
  for node in ghost.getOverlappingNodes():
    print node
  return task.cont
taskMgr.add(checkGhost, 'checkGhost')
Previous Top Next