Scale current lateral velocity by input direction when jumping (not working)

This commit is contained in:
Kevin Poretti 2022-03-26 22:20:41 -04:00
parent c9fb74b90d
commit 88cbe5910c
2 changed files with 11 additions and 4 deletions

Binary file not shown.

View File

@ -208,7 +208,8 @@ bool USNGCharacterMovementComponent::DoJump(bool bReplayingMoves)
FLaunchParameters JumpParams;
FVector WorldInputDir = CharacterOwnerAsSNGChar->GetInputAsWorldDirection();
if(WorldInputDir.Size2D() >= CharacterOwnerAsSNGChar->GetInputThreshold())
bool InputThresholdMet = WorldInputDir.Size2D() >= CharacterOwnerAsSNGChar->GetInputThreshold();
if(InputThresholdMet)
{
FVector JumpLateralVelocity = WorldInputDir * DefaultJumpLateralVelocity;
JumpParams.Velocity.X = JumpLateralVelocity.X;
@ -221,7 +222,13 @@ bool USNGCharacterMovementComponent::DoJump(bool bReplayingMoves)
JumpParams.bOverrideY = false;
JumpParams.bOverrideZ = true;
JumpParams.VelocityScale = FVector(LateralVelocityScaling, 1.0f);
/**
* NOTE(kevin): This is done so that if the player holds nothing the character still carries some lateral
* momentum out of a neutral jump. If the player if moving forward but jumps right (this is all relative
* to the camera) we want all forward momentum canceled and the character to only have velocity going
* up and right.
*/
JumpParams.VelocityScale = FVector(InputThresholdMet ? FVector2D(WorldInputDir.X, WorldInputDir.Y) * LateralVelocityScaling : LateralVelocityScaling, 1.0f);
JumpParams.bUseDefaultGroundFriction = true;
JumpParams.bUseDefaultGravityScale = true;