Running speed can be adjusted from the character configs, added a parameter for the "running speed" in water (characters now swim faster when holding shift).
TODO: make AI-controlled monsters run/swim faster in specific situations (fleeing, attacking, etc).
This commit is contained in:
@@ -9,8 +9,8 @@
|
||||
movementlerp="0.4"
|
||||
legtorque="15.0"
|
||||
thightorque="-5.0"
|
||||
walkspeed="1.5"
|
||||
swimspeed="2.0"
|
||||
walkspeed="1.5" swimspeed="2.0"
|
||||
runspeedmultiplier="3.0" swimspeedmultiplier="1.5"
|
||||
colliderheightfromfloor="55"
|
||||
impacttolerance="7.5">
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
movementlerp="0.4"
|
||||
legtorque="15.0"
|
||||
thightorque="-5.0"
|
||||
walkspeed="1.5"
|
||||
swimspeed="2.5"
|
||||
walkspeed="1.5" swimspeed="2.5"
|
||||
runspeedmultiplier="2.0" swimspeedmultiplier="1.5"
|
||||
impacttolerance="7.5">
|
||||
|
||||
<collider height="80" radius="15"/>
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
movementlerp="0.4"
|
||||
legtorque="15.0"
|
||||
thightorque="-5.0"
|
||||
walkspeed="1.2"
|
||||
swimspeed="2.5">
|
||||
walkspeed="1.2" swimspeed="2.5"
|
||||
runspeedmultiplier="2.0" swimspeedmultiplier="1.5">
|
||||
|
||||
<collider height="80" radius="15"/>
|
||||
<collider height="40" radius="15"/>
|
||||
|
||||
@@ -12,13 +12,25 @@ namespace Barotrauma
|
||||
|
||||
protected Character character;
|
||||
|
||||
protected float walkSpeed, swimSpeed;
|
||||
|
||||
protected float walkSpeed, swimSpeed;
|
||||
|
||||
protected float walkPos;
|
||||
|
||||
protected readonly Vector2 stepSize;
|
||||
protected readonly float legTorque;
|
||||
|
||||
|
||||
public float RunSpeedMultiplier
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public float SwimSpeedMultiplier
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public AnimController(Character character, XElement element)
|
||||
: base(character, element)
|
||||
{
|
||||
@@ -30,6 +42,9 @@ namespace Barotrauma
|
||||
walkSpeed = ToolBox.GetAttributeFloat(element, "walkspeed", 1.0f);
|
||||
swimSpeed = ToolBox.GetAttributeFloat(element, "swimspeed", 1.0f);
|
||||
|
||||
RunSpeedMultiplier = ToolBox.GetAttributeFloat(element, "runspeedmultiplier", 2f);
|
||||
SwimSpeedMultiplier = ToolBox.GetAttributeFloat(element, "swimspeedmultiplier", 1.5f);
|
||||
|
||||
legTorque = ToolBox.GetAttributeFloat(element, "legtorque", 0.0f);
|
||||
}
|
||||
|
||||
|
||||
@@ -571,7 +571,6 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
float targetSpeed = TargetMovement.Length();
|
||||
if (targetSpeed > 0.0f) TargetMovement /= targetSpeed;
|
||||
|
||||
if (targetSpeed > 0.1f)
|
||||
{
|
||||
@@ -633,7 +632,7 @@ namespace Barotrauma
|
||||
Collider.LinearVelocity = Vector2.Lerp(Collider.LinearVelocity, movement * swimSpeed, movementLerp);
|
||||
}
|
||||
|
||||
walkPos += movement.Length() * 0.15f;
|
||||
walkPos += movement.Length() * 0.2f;
|
||||
footPos = Collider.SimPosition - new Vector2((float)Math.Sin(-Collider.Rotation), (float)Math.Cos(-Collider.Rotation)) * 0.4f;
|
||||
|
||||
for (int i = -1; i<2; i+=2)
|
||||
@@ -691,7 +690,7 @@ namespace Barotrauma
|
||||
|
||||
handPos += head.LinearVelocity * 0.1f;
|
||||
|
||||
float handCyclePos = walkPos / 3.0f * -Dir;
|
||||
float handCyclePos = walkPos / 2.0f * -Dir;
|
||||
float handPosX = (float)Math.Cos(handCyclePos) * 0.4f;
|
||||
float handPosY = (float)Math.Sin(handCyclePos) * 1.0f;
|
||||
handPosY = MathHelper.Clamp(handPosY, -0.8f, 0.8f);
|
||||
|
||||
@@ -785,16 +785,14 @@ namespace Barotrauma
|
||||
if (IsKeyDown(InputType.Run))
|
||||
{
|
||||
//can't run if
|
||||
// - not a humanoid
|
||||
// - dragging someone
|
||||
// - crouching
|
||||
// - moving backwards
|
||||
if (AnimController is HumanoidAnimController &&
|
||||
selectedCharacter == null &&
|
||||
if (selectedCharacter == null &&
|
||||
!((HumanoidAnimController)AnimController).Crouching &&
|
||||
Math.Sign(targetMovement.X) != -Math.Sign(AnimController.Dir))
|
||||
{
|
||||
targetMovement *= 3.0f;
|
||||
targetMovement *= AnimController.InWater ? AnimController.SwimSpeedMultiplier : AnimController.RunSpeedMultiplier;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user