SG_Controller* KX_BulletPhysicsController::GetReplica(class SG_Node* destnode) { PHY_IMotionState* motionstate = new KX_MotionState(destnode); KX_BulletPhysicsController* physicsreplica = new KX_BulletPhysicsController(*this); //parentcontroller is here be able to avoid collisions between parent/child PHY_IPhysicsController* parentctrl = NULL; KX_BulletPhysicsController* parentKxCtrl = NULL; CcdPhysicsController* ccdParent = NULL; if (destnode != destnode->GetRootSGParent()) { KX_GameObject* clientgameobj = (KX_GameObject*) destnode->GetRootSGParent()->GetSGClientObject(); if (clientgameobj) { parentctrl = (KX_BulletPhysicsController*)clientgameobj->GetPhysicsController(); } else { // it could be a false node, try the children NodeList::const_iterator childit; for ( childit = destnode->GetSGChildren().begin(); childit!= destnode->GetSGChildren().end(); ++childit ) { KX_GameObject *clientgameobj_child = static_cast<KX_GameObject*>( (*childit)->GetSGClientObject()); if (clientgameobj_child) { parentKxCtrl = (KX_BulletPhysicsController*)clientgameobj_child->GetPhysicsController(); parentctrl = parentKxCtrl; ccdParent = parentKxCtrl; } } } } physicsreplica->setParentCtrl(ccdParent); physicsreplica->PostProcessReplica(motionstate,parentctrl); physicsreplica->m_userdata = (PHY_IPhysicsController*)physicsreplica; physicsreplica->m_bulletChildShape = NULL; return physicsreplica; }