'GetCharacterMovementComponent' identifier not found

Hi, I am new to UE4 development, I was trying to create a demo by following this official tutorial,

but when I copy code to my local IDE, and try to compile my code, it tells me this error message:

FirstCharacter.cpp(99): [C3861] 'GetCharacterMovementComponent': identifier not found

Here is the headers I included in FirstCharacter.cpp:

#include "FirstCharacter.h"
#include "Camera/CameraComponent.h"
#include "GameFramework/SpringArmComponent.h"
#include "GameFramework/CharacterMovementComponent.h"

the headers in FirstCharacter.h:

#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "FirstCharacter.generated.h"

and here are the lines which failed the compile:

void AFirstCharacter::BeginSprint()
{
	GetCharacterMovementComponent()->MaxWalkSpeed = 1000.0f;    
}

My point is, I have already imported “GameFramework/CharacterMovementComponent.h” header, and it does have the MaxWalkSpeed field, why I still can’t access the property in it, Does anyone solved this before?
I am using Version: 4.27.1-17735300+++UE4+Release-4.27 on windows.

If you are inheriting from ACharacter then it already has a CharacterMovementComponent which you can access with:

GetCharacterMovement()
2 Likes