# GetVelocity() flexibility

**URL:** <https://forums.unrealengine.com/t/getvelocity-flexibility/116069>\
**Category:** Feedback & Requests\
**Tags:** unreal-engine\
**Created:** [September 9, 2018, 1:40pm UTC](https://forums.unrealengine.com/t/getvelocity-flexibility/116069 "2018-09-09T13:40:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vorixo](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/vorixo/32/918682_2.png) [@vorixo](https://forums.unrealengine.com/u/vorixo)\
**Post date:** [September 9, 2018, 1:40pm UTC](https://forums.unrealengine.com/t/getvelocity-flexibility/116069/1 "2018-09-09T13:40:17Z")

</div>

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.

```auto

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

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

```

Would translate into:

```auto

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.
