Download

How do I move a character?

I am trying to understand how the movement of the character is working because I need to create a custom movement component.

This is what I’ve got so far:

AddMovementInput is called in the character, which seems to call UPawnMovementComponent instead of the UCharacterMovementComponent, not sure why.

AddMovementInput calls UPawnMovementComponent::AddInputVector which is adding the vector to the ControlInputVector.

The ControlInputVector is really the velocity of the UPawnMovementComponent, so I am assuming that the movement of the character is just based on the velocity.

But I can’t seem to find where the velocity is used to update the location of the actor itself.

Any help is greatly appreciated.

Take a look at the various calls to SafeMoveUpdatedComponent() in UCharacterMovementComponent. How and when movement deltas are applied depends on the movement mode and other aspects of state, but Velocity is calculated in UCharacterMovementComponent::CalcVelocity and in general is applied via SafeMoveUpdatedComponent().