Code: Select all
// Jump & move
if (mo_emgr->KeyPressed(irr::EKEY_CODE::KEY_SPACE) && !AnimatorSpringen->isFalling() && (Player->getPosition().Y <= 0.1))
AnimatorSpringen->jump(0.2f); // Jumping
Greetings,
Squarefox
Code: Select all
// Jump & move
if (mo_emgr->KeyPressed(irr::EKEY_CODE::KEY_SPACE) && !AnimatorSpringen->isFalling() && (Player->getPosition().Y <= 0.1))
AnimatorSpringen->jump(0.2f); // Jumping
I didn't explain myself properly, I'm not talkin about the number of times you call it, I'm talking about how you call it:Squarefox2 wrote:I only call this jump one time, so there are no multiple jumps.
Code: Select all
// MAIN LOOP
while( device->run() && device )
{
... //other code
//// Framerate dependant movement ////
node->setPosition( node->getPosition() + vector3df(1,0,0) );
... //other code
}
Code: Select all
timer = device->getTimer() ;
lastTime = timer->getTime() ;
// MAIN LOOP
while( device->run() && device )
{
//Retrieving Data from timer
newTime = timer->getTime() ;
deltaTime = newTime-lastTime ;
lastTime = newTime ;
... //other code
//// Not framerate dependant movement (note the "* deltaTime")////
node->setPosition( node->getPosition() + ( vector3df(1,0,0) * deltaTime ) / 1000); // "/1000" is needed because deltaTime is in ms
... //other code
}
Code: Select all
Index: CSceneNodeAnimatorCollisionResponse.cpp
===================================================================
--- CSceneNodeAnimatorCollisionResponse.cpp (revision 4908)
+++ CSceneNodeAnimatorCollisionResponse.cpp (working copy)
@@ -189,7 +189,8 @@
= SceneManager->getSceneCollisionManager()->getCollisionResultPosition(
World, LastPosition-Translation,
Radius, vel, CollisionTriangle, CollisionPoint, f,
- CollisionNode, SlidingSpeed, FallingVelocity);
+ CollisionNode, SlidingSpeed, FallingVelocity * (f32)diff * 0.2f);
+ // FallingVelocity is multiplied by 0.2f instead of 0.001f simply because with this value, gravity and jump value don't have to be changed in the Irrlicht examples + demo (Otherwise the solution is to change jump/gravity value in demo, examples 7 and 21).
CollisionOccurred = (CollisionTriangle != RefTriangle);
Code: Select all
Index: source/Irrlicht/CSceneNodeAnimatorCollisionResponse.cpp
===================================================================
--- source/Irrlicht/CSceneNodeAnimatorCollisionResponse.cpp (revision 4915)
+++ source/Irrlicht/CSceneNodeAnimatorCollisionResponse.cpp (working copy)
@@ -270,7 +270,7 @@
CSceneNodeAnimatorCollisionResponse * newAnimator =
new CSceneNodeAnimatorCollisionResponse(newManager, World, Object, Radius,
- (Gravity * 1000.0f), Translation, SlidingSpeed);
+ Gravity, Translation, SlidingSpeed);
newAnimator->cloneMembers(this);
return newAnimator;
}
In relation with this bug, when the gravity vector turns (0 ,0 ,0), sets the Falling variable as False in CSceneCollisionManager::collideEllipsoidWithWorld() method.JLouisB wrote:Up, this bug is still in Irrlicht (also reported here)
My little patch to fix this problem :Package with patch, test case application and comments :Code: Select all
Index: CSceneNodeAnimatorCollisionResponse.cpp =================================================================== --- CSceneNodeAnimatorCollisionResponse.cpp (revision 4908) +++ CSceneNodeAnimatorCollisionResponse.cpp (working copy) @@ -189,7 +189,8 @@ = SceneManager->getSceneCollisionManager()->getCollisionResultPosition( World, LastPosition-Translation, Radius, vel, CollisionTriangle, CollisionPoint, f, - CollisionNode, SlidingSpeed, FallingVelocity); + CollisionNode, SlidingSpeed, FallingVelocity * (f32)diff * 0.20f); + // FallingVelocity is multiplied by 0.020f instead of 0.001f simply because with this value, gravity and jump value don't have to be changed in the Irrlicht examples + demo (Otherwise the solution is to change jump/gravity value in demo, examples 7 and 21). CollisionOccurred = (CollisionTriangle != RefTriangle);
https://dl.dropboxusercontent.com/u/244 ... endant.zip
Can you fix this bug for a next release please ?
Thanks
Code: Select all
Index: CSceneCollisionManager.cpp
===================================================================
Method: collideEllipsoidWithWorld()
- if (gravity != core::vector3df(0,0,0))
+ if (gravityEnabled)
{
colData.R3Position = finalPos * colData.eRadius;
colData.R3Velocity = gravity;
colData.triangleHits = 0;
eSpaceVelocity = gravity/colData.eRadius;
finalPos = collideWithWorld(0, colData,
finalPos, eSpaceVelocity);
outFalling = (colData.triangleHits == 0);
}
It's a mistake, it's 0.2f.should it be 0.20f OR 0.020f ???
The velocity is frame independent and well computed, but it's not the movement at each frame.And i am not so sure about this all. In "CSceneNodeAnimatorCollisionResponse::animateNode" you can find the line
FallingVelocity += Gravity * (f32)diff ...
with diff = timeMs - LastTime. So at least this is frame independent.