BGE: Fix for bug #34349 "Character walkDirection ADD mode -#INF error" reported by Angus Hollands (agoose77). If the walk directions canceled each other out, the actuator would try to normalize a zero vector, which caused the error.

This commit is contained in:
Mitchell Stokes
2013-02-22 02:31:46 +00:00
parent e663f24978
commit 6bac47f854

View File

@@ -221,10 +221,14 @@ bool KX_ObjectActuator::Update()
if (m_bitLocalFlag.AddOrSetCharLoc) {
MT_Vector3 old_dir = parent->GetPhysicsController()->GetWalkDirection();
MT_Scalar mag = old_dir.length();
if (mag < MT_EPSILON)
mag = dir.length();
dir = (dir + old_dir).normalized() * mag;
if (!old_dir.fuzzyZero()) {
MT_Scalar mag = old_dir.length();
dir = dir + old_dir;
if (!dir.fuzzyZero())
dir = dir.normalized() * mag;
}
}
// We always want to set the walk direction since a walk direction of (0, 0, 0) should stop the character