I'm having a big problem with the movement and the gravity. Because if I hold the W or the forward key, it ignores the gravity. Is there checkgravity() function or something like that?
Your problem with gravity, is because you havn't enabled gravity. In order to have gravity, you need to:
1. Implement it yourself using some formula for gravity, or
2. Enable collision detection with smgr->createCollisionResponseAnimator(
triangle selector, node, 1,2,3,4);
where node is what you want collision detection for, 1 is radius of an ellipse used to check collision, 2 is gravity per second, 3 is ellipse translation, and 4 is ellipse sliding value
// create collision response animator and attach it to the camera
ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
selector, camera[1], vector3df(60,100,60),
vector3df(0,-3,0),
vector3df(0,0,0));
I don't have any problems with gravity when I use the up,down,right,left button. But when I use my own event which is W for Forward, S for Backward and etc, it moves first then after pressing it, it check the gravity so I it go down.
Your problem might be that you are moving faster than the gravity can pull you down, so you might want to decrease how fast you move, or increase gravity. Or if you had a flat world, make it so you only move in the x, or z direction.
EDIT: From what code you have supplied, it looks like you are moving at 2 units per frame , and the gravity is 3 units per second, so since there is about a minimum of 60 frames per second, you are moving at, at least 120 units per second, but gravity is only pulling you down at 3 units per second, so it won't seem like gravity is working
The act of moving the object actually disables the effect of the collision animator's gravity so long as you are moving it. So the strength of gravity is not a problem.
I wasn't sure how to solve it so I just made my own gravity and my own simple collision to keep my character above the terrain.