Skip to content

Commit

Permalink
Merge pull request #76 from selimnahimi/vaulting-over-smoothly
Browse files Browse the repository at this point in the history
Vaulting over smoothly
  • Loading branch information
selimnahimi authored Sep 8, 2023
2 parents 6e6d641 + 7523770 commit add875c
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 9 deletions.
42 changes: 41 additions & 1 deletion animgraphs/faith_arms.vanmgrph
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,19 @@
m_data = 10.0
}
},
{
_class = "CParameterAnimCondition"
m_comparisonOp = 0
m_paramID =
{
m_id = 1226064506
}
m_comparisonValue =
{
m_nType = 1
m_data = true
}
},
]
m_blendDuration = 0.2
m_destState =
Expand Down Expand Up @@ -273,6 +286,19 @@
m_data = 10.0
}
},
{
_class = "CParameterAnimCondition"
m_comparisonOp = 0
m_paramID =
{
m_id = 1226064506
}
m_comparisonValue =
{
m_nType = 1
m_data = false
}
},
]
m_blendDuration = 0.2
m_destState =
Expand Down Expand Up @@ -2712,7 +2738,7 @@
},
{
_class = "CBoolAnimParameter"
m_name = "jumping"
m_name = "airborne"
m_id =
{
m_id = 1731058928
Expand Down Expand Up @@ -2836,6 +2862,20 @@
m_fMaxValue = 1000.0
m_bInterpolate = false
},
{
_class = "CBoolAnimParameter"
m_name = "jumping"
m_id =
{
m_id = 1226064506
}
m_previewButton = "ANIMPARAM_BUTTON_NONE"
m_bNetwork = true
m_bUseMostRecentValue = false
m_bAutoReset = false
m_bPredicted = false
m_bDefaultValue = false
},
]
}
m_pTagManager =
Expand Down
3 changes: 2 additions & 1 deletion code/pawn/Pawn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ void UpdateAnimParameters()
{
SetAnimParameter( "speed", Velocity.Length );
SetAnimParameter( "horizontal_speed", Velocity.WithZ(0).Length );
SetAnimParameter( "jumping", !Controller.Grounded );
SetAnimParameter( "airborne", !Controller.Grounded );
SetAnimParameter( "jumping", Controller.Jumping );
SetAnimParameter( "dashing", Controller.Dashing );
SetAnimParameter( "wallrunning", (int)Controller.Wallrunning );
SetAnimParameter( "vaulting", (int)Controller.Vaulting );
Expand Down
3 changes: 3 additions & 0 deletions code/pawn/PawnController.Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ void InitiateLandingOnFloor()
parkouredSinceJumping = false;
parkouredBeforeLanding = false;

Jumping = false;

if ( Entity.Velocity.Length > 100f )
{
CurrentMaxSpeed += 500;
Expand Down Expand Up @@ -238,6 +240,7 @@ void InitiateJump()
{
if ( CanJump() )
{
Jumping = true;
Entity.Velocity = ApplyJump( Entity.Velocity, "jump" );
}
}
Expand Down
26 changes: 19 additions & 7 deletions code/pawn/PawnController.Vaulting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public enum VaultType

float showDebugTime => 3f;
float boxRadius => 20f;
Vector3 velocityAfterVault = Vector3.Zero;

void InitiateVault()
{
Expand Down Expand Up @@ -46,7 +47,7 @@ void ProgressVault()
t: bezierCounter
);

bezierCounter += (vaultSpeed / 100) * Time.Delta;
bezierCounter += (vaultSpeed / 85) * Time.Delta;

Entity.Position = Entity.Position.LerpTo( pos, Time.Delta * 50f );

Expand Down Expand Up @@ -74,6 +75,8 @@ float GetSpeedAfterVault()
{
case VaultType.OntoHigh:
return 0;
case VaultType.Over:
return Entity.Velocity.WithZ( -50 ).Length * 2f;
}

return Entity.Velocity.WithZ( 0 ).Length;
Expand Down Expand Up @@ -323,19 +326,28 @@ void VaultOver( BBox boxBehindObstacle )
color: Color.Blue, duration: showDebugTime
);

Vaulting = VaultType.Over;
vaultSpeed = 200f;

if ( traceObstacleSurface.Hit )
{
var groundPosition = traceObstacleSurface.HitPosition;

VaultTargetPos = groundPosition;
VaultOverAndLand( traceObstacleSurface );
}
else
{
VaultTargetPos = boxBehindObstacle.Center + Entity.Rotation.Up * -40f;
VaultOverAndFall( boxBehindObstacle );
}
}

Vaulting = VaultType.Over;
vaultSpeed = 200f;
void VaultOverAndLand(TraceResult traceObstacleSurface )
{
var groundPosition = traceObstacleSurface.HitPosition;
VaultTargetPos = groundPosition;
}

void VaultOverAndFall( BBox boxBehindObstacle )
{
VaultTargetPos = boxBehindObstacle.Center + Entity.Rotation.Up * -40f;
}

bool CanVaultOnto( BBox topBoxLarge )
Expand Down
1 change: 1 addition & 0 deletions code/pawn/PawnController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public partial class PawnController : EntityComponent<Pawn>
public float TimeSinceClimbing { get; set; }
public float TimeSinceWallrun { get; set; }
public TraceResult CurrentWall { get; set; } = new TraceResult();
public bool Jumping { get; set; }

private int CurrentClimbAmount { get; set; }
public float CurrentMaxSpeed { get; set; }
Expand Down

0 comments on commit add875c

Please sign in to comment.