Fixed ragdolls colliding with stairs when swimming even if not steering upwards, AI steering fixes
This commit is contained in:
@@ -82,10 +82,14 @@ namespace Barotrauma
|
|||||||
else if (leftDist < WallAvoidDistance)
|
else if (leftDist < WallAvoidDistance)
|
||||||
{
|
{
|
||||||
pathSteering.SteeringManual(deltaTime, Vector2.UnitX * (WallAvoidDistance-leftDist)/WallAvoidDistance);
|
pathSteering.SteeringManual(deltaTime, Vector2.UnitX * (WallAvoidDistance-leftDist)/WallAvoidDistance);
|
||||||
|
pathSteering.WanderAngle = 0.0f;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if (rightDist < WallAvoidDistance)
|
else if (rightDist < WallAvoidDistance)
|
||||||
{
|
{
|
||||||
pathSteering.SteeringManual(deltaTime, -Vector2.UnitX * (WallAvoidDistance-rightDist)/WallAvoidDistance);
|
pathSteering.SteeringManual(deltaTime, -Vector2.UnitX * (WallAvoidDistance-rightDist)/WallAvoidDistance);
|
||||||
|
pathSteering.WanderAngle = MathHelper.Pi;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,6 +100,8 @@ namespace Barotrauma
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
character.AIController.SteeringManager.SteeringWander();
|
character.AIController.SteeringManager.SteeringWander();
|
||||||
|
//reset vertical steering to prevent dropping down from platforms etc
|
||||||
|
character.AIController.SteeringManager.ResetY();
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -60,6 +60,16 @@ namespace Barotrauma
|
|||||||
steering = Vector2.Zero;
|
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)
|
public virtual void Update(float speed = 1.0f)
|
||||||
{
|
{
|
||||||
if (steering == Vector2.Zero || !MathUtils.IsValid(steering))
|
if (steering == Vector2.Zero || !MathUtils.IsValid(steering))
|
||||||
|
|||||||
@@ -832,16 +832,14 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
flowForce = GetFlowForce();
|
flowForce = GetFlowForce();
|
||||||
|
|
||||||
inWater = false;
|
|
||||||
headInWater = false;
|
headInWater = false;
|
||||||
|
|
||||||
float waterSurface = ConvertUnits.ToSimUnits(currentHull.Surface);
|
float waterSurface = ConvertUnits.ToSimUnits(currentHull.Surface);
|
||||||
|
|
||||||
float floorY = GetFloorY();
|
float floorY = GetFloorY();
|
||||||
|
|
||||||
if (currentHull.Volume > currentHull.FullVolume * 0.95f ||
|
inWater = currentHull.Volume > currentHull.FullVolume * 0.95f ||
|
||||||
(waterSurface - floorY > HeadPosition * 0.95f && Collider.SimPosition.Y < waterSurface))
|
(waterSurface - floorY > HeadPosition * 0.95f && Collider.SimPosition.Y < waterSurface);
|
||||||
inWater = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flowForce.LengthSquared() > 0.001f)
|
if (flowForce.LengthSquared() > 0.001f)
|
||||||
@@ -1010,6 +1008,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
case Physics.CollisionStairs:
|
case Physics.CollisionStairs:
|
||||||
Structure structure = fixture.Body.UserData as Structure;
|
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;
|
if (colliderBottomDisplay.Y < structure.Rect.Y - structure.Rect.Height + 30 && TargetMovement.Y < 0.5f) return -1;
|
||||||
break;
|
break;
|
||||||
case Physics.CollisionPlatform:
|
case Physics.CollisionPlatform:
|
||||||
@@ -1049,6 +1048,14 @@ namespace Barotrauma
|
|||||||
float tfloorY = rayStart.Y + (rayEnd.Y - rayStart.Y) * closestFraction;
|
float tfloorY = rayStart.Y + (rayEnd.Y - rayStart.Y) * closestFraction;
|
||||||
float targetY = tfloorY + Collider.height * 0.5f + Collider.radius + colliderHeightFromFloor;
|
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)
|
if (Math.Abs(Collider.SimPosition.Y - targetY) > 0.01f && Collider.SimPosition.Y<targetY && !forceImmediate)
|
||||||
{
|
{
|
||||||
Vector2 newSpeed = Collider.LinearVelocity;
|
Vector2 newSpeed = Collider.LinearVelocity;
|
||||||
|
|||||||
@@ -841,10 +841,13 @@ namespace Barotrauma
|
|||||||
ViewTarget = null;
|
ViewTarget = null;
|
||||||
if (!AllowInput) return;
|
if (!AllowInput) return;
|
||||||
|
|
||||||
|
if (!(this is AICharacter) || controlled == this)
|
||||||
|
{
|
||||||
Vector2 targetMovement = GetTargetMovement();
|
Vector2 targetMovement = GetTargetMovement();
|
||||||
|
|
||||||
AnimController.TargetMovement = targetMovement;
|
AnimController.TargetMovement = targetMovement;
|
||||||
AnimController.IgnorePlatforms = AnimController.TargetMovement.Y < 0.0f;
|
AnimController.IgnorePlatforms = AnimController.TargetMovement.Y < 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
if (AnimController is HumanoidAnimController)
|
if (AnimController is HumanoidAnimController)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user