GetVelocity() flexibility

The addition of an exposed boolean variable to have the ability to define which velocity the **Pawn **actors want to get will make definitively easier to work on blueprints with moving pawns without the need of a custom movement component. This should come along with the ability to set the **ComponentVelocity **directly on blueprints.

Why are these changes useful? Because the **GetVelocity **function is the main function when working on movement systems, and for a blueprint only project there is no way to have a reliable way to get the velocity of an object that is not simulating physics or doesn’t have a movement component.

The change on this function will make posible to call **GetVelocity **without having to discriminate the actor type since it belongs to the **AActor **inheritation chain and it is the most reasonable way to make an extendable system.

The change could be as it follows.



FVector APawn::GetVelocity() const
{
    if(GetRootComponent() && GetRootComponent()->IsSimulatingPhysics())
    {
        return GetRootComponent()->GetComponentVelocity();
    }

    const UPawnMovementComponent* MovementComponent = GetMovementComponent();
    return MovementComponent ? MovementComponent->Velocity : FVector::ZeroVector;
}


Would translate into:



FVector APawn::GetVelocity() const
{
    if(GetRootComponent() && (GetRootComponent()->IsSimulatingPhysics() || bUseComponentVelocity))
    {
        return GetRootComponent()->GetComponentVelocity();
    }

    const UPawnMovementComponent* MovementComponent = GetMovementComponent();
    return MovementComponent ? MovementComponent->Velocity : FVector::ZeroVector;
}


In this case **bUseComponentVelocity **would be a “boolean like” variable exposed to blueprints (VisibleDefaultsOnly) that the user could tweak to its willing. It will need to be defaulted to false to support forward compatibility.