0.5 sec delay when switching from swimming to walking or vice versa (prevents rapid switches between swimming/walking if the water level is fluctuating around the minimum swimming depth)
This commit is contained in:
@@ -21,6 +21,9 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private float cprAnimState;
|
private float cprAnimState;
|
||||||
|
|
||||||
|
private float inWaterTimer;
|
||||||
|
private bool swimming;
|
||||||
|
|
||||||
protected override float HeadPosition
|
protected override float HeadPosition
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -44,7 +47,7 @@ namespace Barotrauma
|
|||||||
return Crouching ? base.TorsoAngle+0.5f : base.TorsoAngle;
|
return Crouching ? base.TorsoAngle+0.5f : base.TorsoAngle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public HumanoidAnimController(Character character, XElement element)
|
public HumanoidAnimController(Character character, XElement element)
|
||||||
: base(character, element)
|
: base(character, element)
|
||||||
{
|
{
|
||||||
@@ -220,11 +223,28 @@ namespace Barotrauma
|
|||||||
default:
|
default:
|
||||||
|
|
||||||
if (character.SelectedCharacter != null) DragCharacter(character.SelectedCharacter);
|
if (character.SelectedCharacter != null) DragCharacter(character.SelectedCharacter);
|
||||||
|
|
||||||
|
//0.5 second delay for switching between swimming and walking
|
||||||
|
//prevents rapid switches between swimming/walking if the water level is fluctuating around the minimum swimming depth
|
||||||
if (inWater)
|
if (inWater)
|
||||||
UpdateSwimming();
|
{
|
||||||
|
inWaterTimer = Math.Max(inWaterTimer+deltaTime, 0.5f);
|
||||||
|
if (inWaterTimer >= 1.0f) swimming = true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
inWaterTimer = Math.Min(inWaterTimer - deltaTime, 0.5f);
|
||||||
|
if (inWaterTimer <= 0.0f) swimming = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (swimming)
|
||||||
|
{
|
||||||
|
UpdateSwimming();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
UpdateStanding();
|
UpdateStanding();
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -747,7 +747,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//the limb has gone through the surface of the water
|
//the limb has gone through the surface of the water
|
||||||
if (Math.Abs(limb.LinearVelocity.Y) > 5.0f && inWater != prevInWater)
|
if (Math.Abs(limb.LinearVelocity.Y) > 5.0f && limb.inWater != prevInWater)
|
||||||
{
|
{
|
||||||
|
|
||||||
//create a splash particle
|
//create a splash particle
|
||||||
|
|||||||
Reference in New Issue
Block a user