Access to bUseAccelerationForPaths from C++

Thank you for the hint :slight_smile: I found excellent example in the source code of UnrealTournament (UTCharacter.cpp).
BTW, Your twitch streams about AI are awesome! Can’t wait next stream :slight_smile:


I can’t access to UNavMovementComponent::bUseAccelerationForPaths from C++ code since it’s declared as protected member.

1>..\Source\MedievalTales\Characters\GameCharacter.cpp(44): error C2248: 'UNavMovementComponent::bUseAccelerationForPaths': cannot access protected member declared in class 'UNavMovementComponent'
1>C:\Program Files\Epic Games\UE_4.16\Engine\Source\Runtime\Engine\Classes\GameFramework/NavMovementComponent.h(44): note: see declaration of 'UNavMovementComponent::bUseAccelerationForPaths'
1>C:\Program Files\Epic Games\UE_4.16\Engine\Source\Runtime\Engine\Classes\GameFramework/NavMovementComponent.h(25): note: see declaration of 'UNavMovementComponent'

I have access to it only from Blueprints :frowning: Please make it as public class member.

All you need to do is to extend the movement component in your code and set bUseAccelerationForPaths to whatever your heart desires, or even add an accessor function. No need to change engine-level code.



I am still stuck in this problem, Could you share your solution in detail

Hi! It’s simple:

  1. Create you own component derived from UCharacterMovementComponent. For example:

    class MEDIEVALTALES_API UGameCharacterMovementComponent : public UCharacterMovementComponent

  2. Setup this parameter in constructor:

    UGameCharacterMovementComponent::UGameCharacterMovementComponent(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
    bUseAccelerationForPaths = true;

  3. Replace default character movement component by your:

    AGameCharacter::AGameCharacter(const FObjectInitializer& ObjectInitializer)
    : Super(ObjectInitializer.SetDefaultSubobjectClass(ACharacter::CharacterMovementComponentName))

  4. That is all.

1 Like

This solved my problems. Thank you so much bro.