CrazyLegz
18-04-2009 17:10:32
Hi all,
I have set up a First Person sandbox in which I can experiment some. It's just a large cube in which I can look around and move in first person style, controlling the camera with the mouse and the motion with the w,a,s,d keys. Everything is fine except that I am having some trouble with controlling the motion. My collision body is an Ellipsoid and after applying some force to move forward I fall over which seems logical btw. What is the best way to control this motion? Or am I just using the wrong kind of body?
I've read through alot of topics and wiki articles and so I came to addForce. Am I using it wrong perhaps?
The m_moveAlongXAxis and m_moveAlongZAxis variables are set when the w,a,s,d keys are pressed. When they are released the values are set to 0.0f.
What I basically want is to move when the w,a,s,d keys are pressed and stop moving when they are released, so I won't keep sliding.
Thanks in advance.
Regards,
CrazyLegz.
I have set up a First Person sandbox in which I can experiment some. It's just a large cube in which I can look around and move in first person style, controlling the camera with the mouse and the motion with the w,a,s,d keys. Everything is fine except that I am having some trouble with controlling the motion. My collision body is an Ellipsoid and after applying some force to move forward I fall over which seems logical btw. What is the best way to control this motion? Or am I just using the wrong kind of body?
I've read through alot of topics and wiki articles and so I came to addForce. Am I using it wrong perhaps?
void Player::forceCallBack(OgreNewt::Body* body)
{
Ogre::Real mass;
Ogre::Vector3 inertia;
m_playerBody->getMassMatrix(mass, inertia);
Ogre::Vector3 force(m_moveAlongXAxis, -9.8f, m_moveAlongZAxis);
force *= mass;
m_playerBody->addForce(force);
}
The m_moveAlongXAxis and m_moveAlongZAxis variables are set when the w,a,s,d keys are pressed. When they are released the values are set to 0.0f.
What I basically want is to move when the w,a,s,d keys are pressed and stop moving when they are released, so I won't keep sliding.
Thanks in advance.
Regards,
CrazyLegz.