From 752377018c8d92e1315e395395fe2eb2c18a983e Mon Sep 17 00:00:00 2001 From: Selim Nahimi Date: Fri, 8 Sep 2023 14:27:12 +0200 Subject: [PATCH] Update jumping logic - Added Jumping field to PawnController - Renamed animparam: "jumping" to "airborne" - Added "jumping" animparam to indicate that the player initiated the jumping This will result in a falling animation playing when falling off a ledge, instead of jumping. --- animgraphs/faith_arms.vanmgrph | 42 +++++++++++++++++++++++++++++++- code/pawn/Pawn.cs | 3 ++- code/pawn/PawnController.Util.cs | 3 +++ code/pawn/PawnController.cs | 1 + 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/animgraphs/faith_arms.vanmgrph b/animgraphs/faith_arms.vanmgrph index eb8c017..85b9267 100644 --- a/animgraphs/faith_arms.vanmgrph +++ b/animgraphs/faith_arms.vanmgrph @@ -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 = @@ -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 = @@ -2712,7 +2738,7 @@ }, { _class = "CBoolAnimParameter" - m_name = "jumping" + m_name = "airborne" m_id = { m_id = 1731058928 @@ -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 = diff --git a/code/pawn/Pawn.cs b/code/pawn/Pawn.cs index 37bcaeb..c91be46 100644 --- a/code/pawn/Pawn.cs +++ b/code/pawn/Pawn.cs @@ -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 ); diff --git a/code/pawn/PawnController.Util.cs b/code/pawn/PawnController.Util.cs index 29b06ff..549e3b5 100644 --- a/code/pawn/PawnController.Util.cs +++ b/code/pawn/PawnController.Util.cs @@ -110,6 +110,8 @@ void InitiateLandingOnFloor() parkouredSinceJumping = false; parkouredBeforeLanding = false; + Jumping = false; + if ( Entity.Velocity.Length > 100f ) { CurrentMaxSpeed += 500; @@ -238,6 +240,7 @@ void InitiateJump() { if ( CanJump() ) { + Jumping = true; Entity.Velocity = ApplyJump( Entity.Velocity, "jump" ); } } diff --git a/code/pawn/PawnController.cs b/code/pawn/PawnController.cs index 8f25a90..97609c0 100644 --- a/code/pawn/PawnController.cs +++ b/code/pawn/PawnController.cs @@ -32,6 +32,7 @@ public partial class PawnController : EntityComponent 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; }