Description
getLinearVelocity() of PhysicsCharacter directly returns m_walkDirection, but m_walkDirection is used as per-step displacement in stepForwardAndStrafe (m_targetPosition = m_currentPosition + walkMove), without being multiplied by dt.
// getLinearVelocity() — returns m_walkDirection as-is
btVector3 btKinematicCharacterController::getLinearVelocity() const {
return m_walkDirection + (m_verticalVelocity * m_up);
}
// stepForwardAndStrafe — m_walkDirection used as displacement
m_targetPosition = m_currentPosition + walkMove;
// playerStep — passed directly, no dt scaling
stepForwardAndStrafe(collisionWorld, m_walkDirection);
By contrast, the setVelocityForTimeInterval path (m_useWalkDirection = false) correctly multiplies by dt:
btVector3 move = m_walkDirection * dtMoving;
stepForwardAndStrafe(collisionWorld, move);
Result: every other CollisionObject's getLinearVelocity() returns m/s, but KCC returns m/step — off by a factor of dt.
Suggestion
If changing the native behavior is not feasible, the Javadoc should at least note that callers must divide by dt to recover actual velocity. The current Javadoc makes no mention of this discrepancy, making it a subtle trap for users.
Description
getLinearVelocity()ofPhysicsCharacterdirectly returnsm_walkDirection, butm_walkDirectionis used as per-step displacement instepForwardAndStrafe(m_targetPosition = m_currentPosition + walkMove), without being multiplied bydt.By contrast, the
setVelocityForTimeIntervalpath (m_useWalkDirection = false) correctly multiplies by dt:btVector3 move = m_walkDirection * dtMoving; stepForwardAndStrafe(collisionWorld, move);Result: every other CollisionObject's
getLinearVelocity()returns m/s, but KCC returns m/step — off by a factor ofdt.Suggestion
If changing the native behavior is not feasible, the Javadoc should at least note that callers must divide by
dtto recover actual velocity. The current Javadoc makes no mention of this discrepancy, making it a subtle trap for users.