Can i get referance or pointer to UCharacterMovementComponent in c++

Hello I would ask you about getting UCharacterMovementComponent in c++. Because I need a velocity of character .I did example code below and this didn’t work. Can Somone explain me why that code didn’t work or tell me how get velocity of character. If any sentence was understandable I would apologise for my bad english.

UCharacterMovementComponent* zabojad;
		zabojad= GetCharacterMovement();
		FVector karonek = zabojad->GetLastUpdateVelocity();```

Your code seems okay, I have tested it and it works just fine.
Alternatively you can just use GetVelocity() in your character code, I believe it will give you the same result as GetCharacterMovement()->GetLastUpdateVelocity();

1 Like

Yes My code was good but i forgot add right header xD

fwiw, it’s helpful if you say what class your code is inside, and what classes that descends from.