forked from mirror/openmw-tes3mp
ObstacleCheck: fix evasion issue
The check if (samePosition... would not work as intended because actors do not move in every frame when the framerate is higher than the physics framerate. In that case the actor would change its evasion direction almost every frame.
This commit is contained in:
parent
caa523a959
commit
d233bc483d
2 changed files with 6 additions and 9 deletions
|
@ -163,13 +163,13 @@ namespace MWMechanics
|
|||
{
|
||||
mStuckDuration = 0;
|
||||
mWalkState = State_Evade;
|
||||
chooseEvasionDirection();
|
||||
}
|
||||
}
|
||||
}
|
||||
/* FALL THROUGH */
|
||||
case State_Evade:
|
||||
{
|
||||
chooseEvasionDirection(samePosition);
|
||||
mEvadeDuration += duration;
|
||||
if(mEvadeDuration < DURATION_TO_EVADE)
|
||||
return true;
|
||||
|
@ -191,16 +191,13 @@ namespace MWMechanics
|
|||
actorMovement.mPosition[1] = evadeDirections[mEvadeDirectionIndex][1];
|
||||
}
|
||||
|
||||
void ObstacleCheck::chooseEvasionDirection(bool samePosition)
|
||||
void ObstacleCheck::chooseEvasionDirection()
|
||||
{
|
||||
// change direction if attempt didn't work
|
||||
if (samePosition && (0 < mEvadeDuration))
|
||||
++mEvadeDirectionIndex;
|
||||
if (mEvadeDirectionIndex == NUM_EVADE_DIRECTIONS)
|
||||
{
|
||||
++mEvadeDirectionIndex;
|
||||
if (mEvadeDirectionIndex == NUM_EVADE_DIRECTIONS)
|
||||
{
|
||||
mEvadeDirectionIndex = 0;
|
||||
}
|
||||
mEvadeDirectionIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace MWMechanics
|
|||
float mDistSameSpot; // take account of actor's speed
|
||||
int mEvadeDirectionIndex;
|
||||
|
||||
void chooseEvasionDirection(bool samePosition);
|
||||
void chooseEvasionDirection();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue