Fixed ragdolls colliding with stairs when swimming even if not steering upwards, AI steering fixes

This commit is contained in:
Regalis
2017-02-02 20:39:51 +02:00
parent 32d7be07ee
commit 39f977535d
4 changed files with 35 additions and 9 deletions

View File

@@ -82,10 +82,14 @@ namespace Barotrauma
else if (leftDist < WallAvoidDistance)
{
pathSteering.SteeringManual(deltaTime, Vector2.UnitX * (WallAvoidDistance-leftDist)/WallAvoidDistance);
pathSteering.WanderAngle = 0.0f;
return;
}
else if (rightDist < WallAvoidDistance)
{
pathSteering.SteeringManual(deltaTime, -Vector2.UnitX * (WallAvoidDistance-rightDist)/WallAvoidDistance);
pathSteering.WanderAngle = MathHelper.Pi;
return;
}
}
@@ -96,6 +100,8 @@ namespace Barotrauma
else
{
character.AIController.SteeringManager.SteeringWander();
//reset vertical steering to prevent dropping down from platforms etc
character.AIController.SteeringManager.ResetY();
}
return;

View File

@@ -60,6 +60,16 @@ namespace Barotrauma
steering = Vector2.Zero;
}
public void ResetX()
{
steering.X = 0.0f;
}
public void ResetY()
{
steering.Y = 0.0f;
}
public virtual void Update(float speed = 1.0f)
{
if (steering == Vector2.Zero || !MathUtils.IsValid(steering))

View File

@@ -832,16 +832,14 @@ namespace Barotrauma
{
flowForce = GetFlowForce();
inWater = false;
headInWater = false;
float waterSurface = ConvertUnits.ToSimUnits(currentHull.Surface);
float floorY = GetFloorY();
if (currentHull.Volume > currentHull.FullVolume * 0.95f ||
(waterSurface - floorY > HeadPosition * 0.95f && Collider.SimPosition.Y < waterSurface))
inWater = true;
inWater = currentHull.Volume > currentHull.FullVolume * 0.95f ||
(waterSurface - floorY > HeadPosition * 0.95f && Collider.SimPosition.Y < waterSurface);
}
if (flowForce.LengthSquared() > 0.001f)
@@ -1010,6 +1008,7 @@ namespace Barotrauma
{
case Physics.CollisionStairs:
Structure structure = fixture.Body.UserData as Structure;
if (inWater && targetMovement.Y < 0.5f) return -1;
if (colliderBottomDisplay.Y < structure.Rect.Y - structure.Rect.Height + 30 && TargetMovement.Y < 0.5f) return -1;
break;
case Physics.CollisionPlatform:
@@ -1048,7 +1047,15 @@ namespace Barotrauma
float tfloorY = rayStart.Y + (rayEnd.Y - rayStart.Y) * closestFraction;
float targetY = tfloorY + Collider.height * 0.5f + Collider.radius + colliderHeightFromFloor;
float waterSurface = ConvertUnits.ToSimUnits(currentHull.Surface);
float floorY = GetFloorY();
if (currentHull.Volume > currentHull.FullVolume * 0.95f ||
(waterSurface - floorY > HeadPosition * 0.95f && Collider.SimPosition.Y < waterSurface))
inWater = true;
if (Math.Abs(Collider.SimPosition.Y - targetY) > 0.01f && Collider.SimPosition.Y<targetY && !forceImmediate)
{
Vector2 newSpeed = Collider.LinearVelocity;

View File

@@ -840,11 +840,14 @@ namespace Barotrauma
{
ViewTarget = null;
if (!AllowInput) return;
Vector2 targetMovement = GetTargetMovement();
AnimController.TargetMovement = targetMovement;
AnimController.IgnorePlatforms = AnimController.TargetMovement.Y < 0.0f;
if (!(this is AICharacter) || controlled == this)
{
Vector2 targetMovement = GetTargetMovement();
AnimController.TargetMovement = targetMovement;
AnimController.IgnorePlatforms = AnimController.TargetMovement.Y < 0.0f;
}
if (AnimController is HumanoidAnimController)
{