marceloharmonia
10-07-2009 21:34:20
Hi, I read the documentation of PhysX and tried use NxCharacter to apply a physics to character, but I can not add gravity to it. The PhysX docs said that I have to apply gravity through of move function and tried to use this code in framelistener:
But the character Y axis decreases continuously, and I want know how I detect the collision of the character with floor (or terrain) and do the d.y = 0, doing the character don't through the floor (or terrain)? I tried use callback, but this don't work...
Thanks!
NxVec3 d(0,0,0);
if(mKeyboard->isKeyDown(OIS::KC_UP)) d.z = -10*time;
if(mKeyboard->isKeyDown(OIS::KC_DOWN)) d.z = 10*time;
if(mKeyboard->isKeyDown(OIS::KC_RIGHT)) d.x = 10*time;
if(mKeyboard->isKeyDown(OIS::KC_LEFT)) d.x = -10*time;
NxF32 sharpness = 1.0f;
NxU32 collisionFlags;
d.y = -9.8*time;
control->move(d, COLLIDABLE_MASK, 0.000001f, collisionFlags, sharpness);
NxVec3 NxPos = act->getGlobalPosition();
Ogre::Vector3 offset(4,40,0);
mPlayerNode->setPosition(Ogre::Vector3(NxPos.x,NxPos.y,NxPos.z) - offset);
But the character Y axis decreases continuously, and I want know how I detect the collision of the character with floor (or terrain) and do the d.y = 0, doing the character don't through the floor (or terrain)? I tried use callback, but this don't work...
Thanks!