A Small Bug in CharacterRigidBody/CharacterControl Demo

A Small Bug in CharacterRigidBody/CharacterControl Demo

Hi. There is a small bug in the demos of CharacterRigidBody. In the code that "skips frames in air", it remembers old skips, and therefore gives false inAir state transitions. for example, in the demo mentioned above, if you crouch, it will swich to inAir state every two crouches.
to fix it, you can use:

const int skipFramesInAir = 3;
if (input.m_wantJump)
{
m_framesInAir = skipFramesInAir;
m_mustBeInAir = true;
}

if ( ground.m_supportedState != hkpSurfaceInfo::SUPPORTED )
{
m_mustBeInAir = false;
if (m_framesInAir < skipFramesInAir)
{
input.m_isSupported = true;
input.m_surfaceNormal = m_previousGround->m_surfaceNormal;
input.m_surfaceVelocity = m_previousGround->m_surfaceVelocity;
input.m_surfaceMotionType = m_previousGround->m_surfaceMotionType;
}
else
{
input.m_isSupported = false;
input.m_surfaceNormal = ground.m_surfaceNormal;
input.m_surfaceVelocity = ground.m_surfaceVelocity;
input.m_surfaceMotionType = ground.m_surfaceMotionType;
}

m_framesInAir++;
}
else
{
input.m_isSupported = true;
input.m_surfaceNormal = ground.m_surfaceNormal;
input.m_surfaceVelocity = ground.m_surfaceVelocity;
input.m_surfaceMotionType = ground.m_surfaceMotionType;

m_previousGround->set(ground);

// reset old number of frames
if(m_framesInAir > skipFramesInAir)
{
char buffer[512];
sprintf(buffer, "farmes in air : %d", m_framesInAir);
LOG4CXX_DEBUG(logger,buffer);
}
if (!m_mustBeInAir)
{
m_framesInAir = 0;
}
}

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi yochay,

Thanks for the heads up. I was able to see this in the demo. If you find anything else, let us know.

Cheers,
Sean

Developer Support Engineer Havok www.havok.com

Leave a Comment

Please sign in to add a comment. Not a member? Join today