Collider height from floor can be changed in the xml files, moved human collider a bit higher to allow climbing over roughly waist-high obstacles
This commit is contained in:
@@ -11,10 +11,11 @@
|
|||||||
thightorque="-5.0"
|
thightorque="-5.0"
|
||||||
walkspeed="1.5"
|
walkspeed="1.5"
|
||||||
swimspeed="2.0"
|
swimspeed="2.0"
|
||||||
impacttolerance="7.5">
|
impacttolerance="7.5"
|
||||||
|
colliderheightfromfloor="55">
|
||||||
|
|
||||||
<collider height="80" radius="15"/>
|
<collider height="60" radius="15"/>
|
||||||
<collider height="40" radius="15"/>
|
<collider height="30" radius="15"/>
|
||||||
|
|
||||||
<!-- head -->
|
<!-- head -->
|
||||||
<limb id = "0" radius="13" mass = "6" type="Head" attackpriority="2">
|
<limb id = "0" radius="13" mass = "6" type="Head" attackpriority="2">
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ namespace Barotrauma
|
|||||||
protected bool inWater, headInWater;
|
protected bool inWater, headInWater;
|
||||||
public bool onGround;
|
public bool onGround;
|
||||||
private bool ignorePlatforms;
|
private bool ignorePlatforms;
|
||||||
|
|
||||||
|
private float colliderHeightFromFloor;
|
||||||
|
|
||||||
protected Structure stairs;
|
protected Structure stairs;
|
||||||
|
|
||||||
@@ -101,7 +103,7 @@ namespace Barotrauma
|
|||||||
if (collider[colliderIndex].height<collider[value].height)
|
if (collider[colliderIndex].height<collider[value].height)
|
||||||
{
|
{
|
||||||
Vector2 pos1 = collider[colliderIndex].SimPosition;
|
Vector2 pos1 = collider[colliderIndex].SimPosition;
|
||||||
pos1.Y -= collider[colliderIndex].height * 0.45f;
|
pos1.Y -= collider[colliderIndex].height * colliderHeightFromFloor;
|
||||||
Vector2 pos2 = pos1;
|
Vector2 pos2 = pos1;
|
||||||
pos2.Y += collider[value].height * 1.1f;
|
pos2.Y += collider[value].height * 1.1f;
|
||||||
if (GameMain.World.RayCast(pos1, pos2).Any(f => f.CollisionCategories.HasFlag(Physics.CollisionWall))) return;
|
if (GameMain.World.RayCast(pos1, pos2).Any(f => f.CollisionCategories.HasFlag(Physics.CollisionWall))) return;
|
||||||
@@ -300,6 +302,9 @@ namespace Barotrauma
|
|||||||
|
|
||||||
CanEnterSubmarine = ToolBox.GetAttributeBool(element, "canentersubmarine", true);
|
CanEnterSubmarine = ToolBox.GetAttributeBool(element, "canentersubmarine", true);
|
||||||
|
|
||||||
|
colliderHeightFromFloor = ToolBox.GetAttributeFloat(element, "colliderheightfromfloor", 45.0f);
|
||||||
|
colliderHeightFromFloor = ConvertUnits.ToSimUnits(colliderHeightFromFloor);
|
||||||
|
|
||||||
collider = new List<PhysicsBody>();
|
collider = new List<PhysicsBody>();
|
||||||
|
|
||||||
foreach (XElement subElement in element.Elements())
|
foreach (XElement subElement in element.Elements())
|
||||||
@@ -994,7 +999,7 @@ namespace Barotrauma
|
|||||||
break;
|
break;
|
||||||
case Physics.CollisionPlatform:
|
case Physics.CollisionPlatform:
|
||||||
Structure platform = fixture.Body.UserData as Structure;
|
Structure platform = fixture.Body.UserData as Structure;
|
||||||
if (IgnorePlatforms || lowestLimb.Position.Y < platform.Rect.Y) return -1;
|
if (IgnorePlatforms || lowestLimb.Position.Y < platform.Rect.Y-16) return -1;
|
||||||
break;
|
break;
|
||||||
case Physics.CollisionWall:
|
case Physics.CollisionWall:
|
||||||
break;
|
break;
|
||||||
@@ -1027,7 +1032,7 @@ 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 + ConvertUnits.ToSimUnits(45.0f);
|
float targetY = tfloorY + Collider.height * 0.5f + Collider.radius + colliderHeightFromFloor;
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user