Skip to content

Commit

Permalink
Merge pull request #91 from selimnahimi/vault-onto-high-patch
Browse files Browse the repository at this point in the history
Vault onto high patch
  • Loading branch information
selimnahimi authored Sep 9, 2023
2 parents 86a7d5a + de9e198 commit 1c3eb84
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions animgraphs/faith_arms.vanmgrph
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
m_sNote = ""
m_tagSpans = [ ]
m_sequenceName = "VaultOntoHigh"
m_playbackSpeed = 1.5
m_playbackSpeed = 1.3
m_bLoop = false
}
},
Expand Down Expand Up @@ -75,7 +75,7 @@
m_sNote = ""
m_tagSpans = [ ]
m_sequenceName = "vaultontohigh02"
m_playbackSpeed = 1.5
m_playbackSpeed = 1.3
m_bLoop = false
}
},
Expand Down
7 changes: 6 additions & 1 deletion code/pawn/PawnController.Vaulting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,15 @@ void ProgressVault()
{
// TODO: make smoother

// TODO: put this into a class or something
var startCurveSize = Vaulting == VaultType.OntoHigh ? 10f : 30f;
var endCurveSize = Vaulting == VaultType.OntoHigh ? -70f : 30f;

Vector3 pos = Bezier.Approach(
start: VaultStartPos,
end: VaultTargetPos,
curveSize: 30f,
startCurveSize: startCurveSize,
endCurveSize: endCurveSize,
t: bezierCounter
);

Expand Down
10 changes: 7 additions & 3 deletions code/util/Bezier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ namespace RunnerVision;
public class Bezier
{
// Source: https://programmerbay.com/c-program-to-draw-bezier-curve-using-4-control-points/
public static Vector3 Approach( Vector3 start, Vector3 end, float curveSize, float t )
public static Vector3 Approach( Vector3 start, Vector3 end, float startCurveSize, float endCurveSize, float t )
{
var cp1 = start + Vector3.Up * curveSize;
var cp2 = end + Vector3.Up * curveSize;
var cp1 = start + Vector3.Up * startCurveSize;
var cp2 = end + Vector3.Up * endCurveSize;
float x = (float)(Math.Pow( 1 - t, 3 ) * start.x + 3 * t * Math.Pow( 1 - t, 2 ) * cp1.x + 3 * t * t * (1 - t) * cp2.x + Math.Pow( t, 3 ) * end.x);
float y = (float)(Math.Pow( 1 - t, 3 ) * start.y + 3 * t * Math.Pow( 1 - t, 2 ) * cp1.y + 3 * t * t * (1 - t) * cp2.y + Math.Pow( t, 3 ) * end.y);
float z = (float)(Math.Pow( 1 - t, 3 ) * start.z + 3 * t * Math.Pow( 1 - t, 2 ) * cp1.z + 3 * t * t * (1 - t) * cp2.z + Math.Pow( t, 3 ) * end.z);

return new Vector3( x, y, z );
}
public static Vector3 Approach( Vector3 start, Vector3 end, float curveSize, float t )
{
return Approach( start, end, curveSize, curveSize, t );
}
}

0 comments on commit 1c3eb84

Please sign in to comment.