Character Controller , collision error !

Devgame

07-04-2010 10:47:07

Hi everyone !
I just use nxogre soon,it's very convenient and great.
But I encountered some problems about Nxogre Character Controller Addon.

I make a game demo, one character move anywhere with collision,used character controller addon.
But not collision,this is my code:

1.First,I create a character with Character Controller.

ControllerDescription desc;
desc.mPosition.set(0,0,0);
desc.mCallback = this;
m_NxRenderable = PhysicsWorld::getInstance().getPhysicsRenderSystem()->createPointRenderable("character.mesh");
m_NxController = m_NxControllerMgr->createCapsuleController(desc, Vec2(200,200), PhysicsWorld::getInstance().getPhysicsScene() , m_NxRenderable );


2.I create a box test collistion

NxOgre::RigidBodyDescription des;
des.mType = NxOgre::Enums::RigidBodyType_Geometry;
des.mBodyFlags |= NxOgre::Enums::BodyFlags_FreezePosition;
des.mGroup = GROUP_COLLIDABLE_NON_PUSHABLE;
OGRE3DBody* mCube = m_pPhysicsRenderSystem->createBody(new NxOgre::Box(100, 100, 100), NxOgre::Vec3(1300, 0, 1300), "cube.mesh",des);
mCube->setGroup(GROUP_COLLIDABLE_NON_PUSHABLE);
mCube->getEntity()->getParentNode()->setScale(5,5,5);


3.The move code:

m_NxController->move(NxOgre::Vec3(-1,0,0),COLLIDABLE_MASK, 0.001f, flag);



enum CollisionGroup
{
GROUP_NON_COLLIDABLE,
GROUP_COLLIDABLE_NON_PUSHABLE,
GROUP_COLLIDABLE_PUSHABLE
};

#define COLLIDABLE_MASK (1<<GROUP_COLLIDABLE_NON_PUSHABLE)


The Question:
When the character move to cube.mesh position,pass through it.
I think this code is problem,the code des.mBodyFlags |= NxOgre::Enums::BodyFlags_FreezePosition;
remark this code , the character can collision , but the cube.mesh have Gravity and affected by physical.

I mean , i want cube.mesh like a wall, the character not affected it , the character not pass through it.

The problem is not here?

NxOgre::RigidBodyDescription des;
des.mType = NxOgre::Enums::RigidBodyType_Geometry;
des.mBodyFlags |= NxOgre::Enums::BodyFlags_FreezePosition;
des.mGroup = GROUP_COLLIDABLE_NON_PUSHABLE;


I'm sorry , my english is poor! I hope this demo like PhysX's Character Controller demo ,Thanks.