C++ Disable Player input when melee attacking

you can cache it. With cache I mean save this pointer reference in a variable and use this variable instead to go and get this reference every time.

So, create a private pointer in your header (.h) file such as

private:
UCharacterMovementComponent* MoveCompRef = nullptr;

then properly fill its value in your .cpp

void ARPGCharacter::BeginPlay()
{
  MoveCompRef = GetCharacterMovement();
}

Now you can use MoveCompRef wherever you want with

if(MoveCompRef) //always check that is different from nullptr
{
  //use MoveCompRef 
}

good luck