Hi, I’m trying to get the acceleration of my character using this code:
GetCharacterMovement()->GetCurrentAcceleration()
But it the compiler is returning the error:
error C2027: use of undefined type ‘UCharacterMovementComponent’
note: see declaration of ‘UCharacterMovementComponent’
error C2227: left of ‘->GetCurrentAcceleration’ must point to class/struct/union/generic type
I’m sure I’ve used this in the past, but idk what I could be missing now.
No, VS won’t automatically find all the headers for you and add the references (previously the monolithic headers did that at the cost of a longer compile time). You need to manually specify them now.
Most (like 95%) of classes are found in files that use the same name (i.e. UCharacterMovementComponent is in CharacterMovementComponent.h which is in the GameFramework directory, hence “GameFramework/CharacterMovementComponent.h”).
I normally just search for the class name (if you use Visual Assist, you can just type ALT+SHIFT+O and it’ll bring up all files in the solution, and you can search that way). Or simply do a find in files for the class name and find where it’s declared.