Problem with Character

Linaxys

25-08-2009 11:54:24

Hello,
I'm trying to make my FPS camera with a CapsuleCollisionShape.

The result is that : View My Video
It jumps randomly sometimes and the speed is not really good, I think increasing the gravity is not the good solution.

I create the world's mesh :

Ogre::Plane plane;
plane.normal = Ogre::Vector3::UNIT_Y;
plane.d = 100;

Ogre::MeshManager::getSingleton().createPlane("planeMesh",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
1500,1500,20,20,true,1,60,60,Ogre::Vector3::UNIT_Z);

Ogre::Entity* planeEnt = m_SceneMgr->createEntity( "plane", "planeMesh" );
planeEnt->setMaterialName("Examples/Rockwall");
planeEnt->setCastShadows(false);
Ogre::SceneNode *planeNode = m_SceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(0,0,0));
planeNode->attachObject(planeEnt);

OgreBulletCollisions::StaticMeshToShapeConverter *trimeshConverter = new OgreBulletCollisions::StaticMeshToShapeConverter(planeEnt);
OgreBulletCollisions::TriangleMeshCollisionShape *sceneTriMeshShape = trimeshConverter->createTrimesh();
delete trimeshConverter;
OgreBulletDynamics::RigidBody *planeRigid = new OgreBulletDynamics::RigidBody("planeRigid", oWorld);
planeRigid->setStaticShape(planeNode, sceneTriMeshShape, 0.0f, 0.8f, Ogre::Vector3::ZERO);


The player's creation :

m_Shape = new OgreBulletCollisions::CapsuleCollisionShape(8, 15, Ogre::Vector3::UNIT_Y);
m_Body = new OgreBulletDynamics::RigidBody("playerBody", m_DynamicsWorld);
Ogre::SceneNode *cameraNode = m_SceneMgr->getRootSceneNode()->createChildSceneNode("playerNode");
cameraNode->attachObject(m_Camera);

m_Body->setShape(cameraNode, m_Shape, 0.0f, 0.0f, 1.0f, m_Camera->getPosition());
m_Body->getBulletRigidBody()->setSleepingThresholds(0.0f,0.0f);
m_Body->getBulletRigidBody()->setRestitution(0.0f);
m_Body->getBulletRigidBody()->setAngularFactor(0.0f);
m_Body->setLinearVelocity(Ogre::Vector3(0,-50,0));


Player movement and rotation :

void Player::Move(bool fwd, bool bck, bool rgt, bool lft, bool up, bool dwn)
{
Ogre::Vector3 walkDirection = m_Body->getLinearVelocity();
Ogre::Real newVelX = 0, newVelY = walkDirection.y, newVelZ = 0;
Ogre::Quaternion quat = m_Camera->getOrientation();

if (lft)
newVelX = -100;

if (rgt)
newVelX = 100;

if (fwd)
newVelZ = -100;

if (bck)
newVelZ = 90;

walkDirection = quat * Ogre::Vector3(newVelX,0,newVelZ);
walkDirection.y = newVelY;

m_Body->setLinearVelocity(walkDirection);
}

void Player::Rotate(int axisX, int axisY)
{
Ogre::Real oldPitch = m_Camera->getOrientation().getPitch().valueDegrees();
Ogre::Real oldYaw = m_Camera->getOrientation().getYaw().valueDegrees();

if (m_Camera->getOrientation().getPitch().valueDegrees() < 85 &&
m_Camera->getOrientation().getPitch().valueDegrees() > -85)
m_Camera->pitch( Ogre::Degree(axisY * -0.1) );
if (m_Camera->getOrientation().getPitch().valueDegrees() >= 85 ||
m_Camera->getOrientation().getPitch().valueDegrees() <= -85)
m_Camera->pitch( Ogre::Degree(axisY * 0.1) );

m_Camera->yaw( Ogre::Degree(axisX * -0.1) );
}


Can someone tell me what I am doing wrong, please ?

Thanks for your replies.

Fish

25-08-2009 22:12:04

Can you put the video on YouTube?



Trend Micro OfficeScan Event

URL Blocked

The URL that you are attempting to access is a potential security risk. Trend Micro OfficeScan has blocked this URL in keeping with network security policy.
URL: http://fr.tinypic.com/r/290znsh/3
Risk Level: High Medium Low
Details: For more information about this URL or to report it to Trend Micro for reclassification,visit http://reclassify.wrs.trendmicro.com.

Linaxys

25-08-2009 23:17:50

Hey,
Sure : http://www.youtube.com/watch?v=0txGavq51io

Thanks.

Fish

26-08-2009 04:04:22

Try printing your walkDirection.y to a log file so you can see what's happening to your y velocity as the character moves. Dynamic character controllers are generally more difficult to achieve expected behaviors. Most of the folks on the Bullet forums will recommend that you use a btKinematicCharacterController for your character controller. Even the Bullet developers tried implementing a Dynamic Character Controller but shelved it in favor of a Kinematic Character Controller. Try doing a search on the Bullet forums to learn more about that.

-Fish

iisystem

13-10-2009 11:47:18

Hi,

I'm also using btKinematicCharacterController, and wondering is it possible to force it jumping?
jump() seems to be not working...

Fish

13-10-2009 18:54:34

Hi,

I'm also using btKinematicCharacterController, and wondering is it possible to force it jumping?
jump() seems to be not working...

If you look at the source for the controller you'll see that the jump() method is essentially empty. So at this time in the classes development it is up to you to fill out the jump method.