This is exactly what i am talking about:
http://www.youtube.com/watch?v=PmwEWEHKEbg
We would like our player to react with other bodies not only 'collide' - our player can't even move a lamp, with a mass of 1, not even mentioning - he can't move anything.
This is how character is made:
Code: Select all
btTransform startTransform;
startTransform.setIdentity ();
startTransform.setOrigin (btVector3(newPosition.x,newPosition.y,newPosition.z));
newActor.m_ghostObject = new btPairCachingGhostObject();
newActor.m_ghostObject->setWorldTransform(startTransform);
Game->Physics()->m_broadphase->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());
btScalar characterHeight=newActor.a_Model.getModel()->modelSize.y;
btScalar characterWidth =newActor.a_Model.getModel()->modelSize.x;
btConvexShape* capsule = new btCapsuleShape(characterWidth,characterHeight);
newActor.m_ghostObject->setCollisionShape (capsule);
newActor.m_ghostObject->setCollisionFlags (btCollisionObject::CF_CHARACTER_OBJECT );
btScalar stepHeight = btScalar(0.35);
newActor.m_character = new btKinematicCharacterController (newActor.m_ghostObject,capsule,stepHeight);
Game->Physics()->getDynamic()->addCollisionObject(newActor.m_ghostObject,X::XCollisionGroups::PLAYERS,X::XCollidesWith::WITH_EVERYTHING);
Game->Physics()->getDynamic()->addAction(newActor.m_character);