Decapitation in the BGE?

I’m trying to have a character be decapitated (from a first person perspective). What I was trying to do was add a head-shaped (invisible) object of dynamic physics type, parent that to the cube I’m using as the player’s base, and then parent the camera to the head object- when it’s decapitation time, use a parent actuator to clear the head’s parent. The only problem is that this doesn’t work, the camera just stops moving altogether. Is there any way for me to do this besides plain old animation? I’d like for the head to act differently (ie. fly forward vs fall straight down) based on how fast the player is going.

I can’t speak extremely intelligently on this but I believe if you used python to instead add a new object that is a rigid body and then set the parent of the camera to the new object then you might be in the money

I tried to do that, but I get the error:
Python script error - object ‘Main Camera’, controller ‘decapPy’:
Traceback (most recent call last):
File “decapitation.py”, line 5, in <module>
AttributeError: ‘module’ object has no attribute ‘data’

import bge
from bge import logic
cont = bge.logic.getCurrentController()
own = cont.owner
headCollision = bge.data.objects['Head Collision']
playCam = scene.active_camera
touchPianoWire = cont.sensors['touch pwire']
headCol = scene.addObject('headCollision', 'camera')

That’s my current python script, what am I doing wrong?

The bge module don’t have any attribute named data. Bge python api

If you are trying to get an object, use this:

scene = bge.logic.getCurrentScene()
object = scene.objects["object name"]

Ah, thank you! I must have been using a regular blender guide, then.