The lowest point of a character collider is calculated from its AABB (works correctly now even if the collider is rotated, allowing prone characters to be dragged through stairs), dragged characters collide with stairs when climbing up, the AI of unconscious or stunned characters isn't updated

This commit is contained in:
Regalis
2017-02-17 19:27:54 +02:00
parent 1ea3044fd6
commit 99cf438ed7
3 changed files with 24 additions and 5 deletions

View File

@@ -47,7 +47,7 @@ namespace Barotrauma
AnimController.SimplePhysicsEnabled = false;
}
if (isDead || health <= 0.0f) return;
if (IsDead || Health <= 0.0f || IsUnconscious || Stun > 0.0f) return;
if (Controlled == this || !aiController.Enabled) return;

View File

@@ -932,6 +932,9 @@ namespace Barotrauma
{
target.AnimController.TargetMovement = Vector2.Lerp(target.AnimController.TargetMovement, (character.SimPosition + Vector2.UnitX * Dir) - target.SimPosition, 0.5f);
}
//if on stairs, make the dragged character "climb up" (= collide with stairs)
if (stairs != null) target.AnimController.TargetMovement = new Vector2 (target.AnimController.TargetMovement.X, 1.0f);
}
public void Grab(Vector2 rightHandPos, Vector2 leftHandPos)

View File

@@ -1268,10 +1268,26 @@ namespace Barotrauma
{
float halfHeight = Collider.height * 0.5f + Collider.radius;
Vector2 offset = Vector2.Zero;
offset.Y = -colliderHeightFromFloor;
return Collider.SimPosition + offset +
new Vector2((float)Math.Sin(Collider.Rotation), -(float)Math.Cos(Collider.Rotation)) * halfHeight;
float offset = 0.0f;
if (!character.IsUnconscious && !character.IsDead && character.Stun <= 0.0f)
{
offset = -colliderHeightFromFloor;
}
float lowestBound = Collider.SimPosition.Y;
for (int i = 0; i < Collider.FarseerBody.FixtureList.Count; i++)
{
FarseerPhysics.Collision.AABB aabb;
FarseerPhysics.Common.Transform transform;
Collider.FarseerBody.GetTransform(out transform);
Collider.FarseerBody.FixtureList[i].Shape.ComputeAABB(out aabb, ref transform, i);
lowestBound = Math.Min(aabb.LowerBound.Y, lowestBound);
}
return new Vector2(Collider.SimPosition.X, lowestBound + offset);
}
public Limb FindLowestLimb()