Highest location the character can reach with current Velocity

My character is going up, maybe because he jumped, or maybe he was launched from a spring or a bouncy mushroom, regardless, he will have a current Velocity.Z and a gravity of GetPhysicsVolume()->GetGravityZ * GravityScale, which, for now, is -1300.f.

This check is for finding out if he can make the jump when he is in range of a ledge, and it will only grab if he can’t make the jump, this way the movement feels a lot more fluid.

What I have:

  • Gravity of -1300.f
  • Velocity is deducted at CurrentVelocity - 1300.f * DeltaTime; with checks for terminal velocity that we don’t need (because we’re going up)
  • An arbitrary FVector

What I need:

  • Whether the current velocity can raise the Character’s location above the arbitrary FVector’s Z.

Appreciate any help. I’m trying to avoid using the initial velocity of the launch for now, it’s a last resort because I want my system to be more flexible and not reliant on being fed values.

Figured it out.

const float ZPeak = FMath::Square(Velocity.Z) / (-2.f * GetGravityZ());
const FVector PeakLocation = CharacterOwner->GetActorLocation() + FVector(0.f, 0.f, ZPeak + CharacterOwner->GetCapsuleComponent()->GetScaledCapsuleHalfHeight());