[SOLVED]CollisionResponseAnimator problem (frame dependent)?
Posted: Mon Apr 13, 2020 11:36 pm
Hi there,
I am not quite a beginner on Irrlicht because I have been working on a small game for several years on my free time, however, I am confronted for a while on a small problem of beginner.
I noticed that the gravity affecting my player change completely depending on the framerate.
I use very basic stuff to apply gravity to my player: The player is a "ISceneNode" and the gravity is done by a "ISceneNodeAnimatorCollisionResponse".
My problem is that I noticed that when the framerate is lower, the gravity is lower, the sceneNode fell more slowly, as if it was floating in the air, and he jumps much lower when I use the "jump ()" method of the animator. I really don't know what is wrong.
I'm pretty sure gravity in Irrlicht is frame independent and is based on elapsed time between frames, so I don't understand.
I did a lot of research on the forum but did not find an answer allowing me to understand and solve this problem. I also did a lot of testing and the calculation of the time between two frames is done correctly, I have different functions that use this process in my program. Only the gravity calculated by Irrlicht is problematic ...
Have you got an idea of what can be causing this troubles?
Thank you in advance to those who will take the time to read this message and reply to me.
I post below some extracts of my code.
The player and animator:
The jump event (in game loop, before drawing any graphics on screen):
I am not quite a beginner on Irrlicht because I have been working on a small game for several years on my free time, however, I am confronted for a while on a small problem of beginner.
I noticed that the gravity affecting my player change completely depending on the framerate.
I use very basic stuff to apply gravity to my player: The player is a "ISceneNode" and the gravity is done by a "ISceneNodeAnimatorCollisionResponse".
My problem is that I noticed that when the framerate is lower, the gravity is lower, the sceneNode fell more slowly, as if it was floating in the air, and he jumps much lower when I use the "jump ()" method of the animator. I really don't know what is wrong.
I'm pretty sure gravity in Irrlicht is frame independent and is based on elapsed time between frames, so I don't understand.
I did a lot of research on the forum but did not find an answer allowing me to understand and solve this problem. I also did a lot of testing and the calculation of the time between two frames is done correctly, I have different functions that use this process in my program. Only the gravity calculated by Irrlicht is problematic ...
Have you got an idea of what can be causing this troubles?
Thank you in advance to those who will take the time to read this message and reply to me.
I post below some extracts of my code.
The player and animator:
Code: Select all
/* The player is loaded from a .irr scene containing the sceneNode */
scene::ISceneNode* playerNode = sceneManager->getSceneNodeFromName(playerNodeName);
scene::ISceneNodeAnimatorCollisionResponse* playerNodeColResponse = sceneManager->createCollisionResponseAnimator(
terrainMeta, // world (scene::IMetaTriangleSelector),
playerNode, // SceneNode
core::vector3df(18, 1, 18), //ellipsoidRadius
core::vector3df(0, 0 - 2.0f, 0), //gravityPerSecond
core::vector3df(0, 0, 0) //ellipsoidTranslation
);
Code: Select all
if(!jumping && controller->isAPressed() == true){
//Start jump animation
jumping = true;
playerNodeColResponse->jump(1.2f);
// Display this text in a console to be sure the jump happens only one time
cout << "jump!" << endl;
}