how to override APawn::GetGravityDirection()?


is it possible to override APawn::GetGravityDirection()?

if so, how?


I am bumping this, as I would also like to know how to straight up disable the physics.

You’ve already found the function, so I’d have thought it were obvious - create a new Pawn or Character class and implement GetGravityDirection(). That’s all there is to it.

‘Physics’ encompasses a lot of things, from movement handling to collision to constraints; I suspect you don’t want to disable everything.

no its not obvious sorry

FVector GetGravityDirection() override;
produces a compile error

Error	1	error C3668: 'AFirstPersonCharacter::GetGravityDirection' : method with override specifier 'override' did not override any base class methods	C:\UE4Projects\FirstPerson\Source\FirstPerson\Public\FirstPersonCharacter.h	84	1	FirstPerson

of course i can change it in APawn but that would mess up all pawns, and i only want to mess up one of them

The function isn’t virtual, so why are you using the override keyword?

so override is only for virtual functions

thanks ambershee :slight_smile:

@ The Britain
what are you trying to do?

bah it doesnt do anything, must be all those GravityZ functions all over the place
guess a different approach is called for, oh well

Yep, override is a new thing in C++11, it’s only used with virtual functions:

Shame implementing the function doesn’t solve your needs, though I can’t say i’m surprised. Gravity is hard-coded all over the place; I seem to recall someone on these forums writing a quick article about where they overrode various functions to achieve non-standard gravity, you may be able to find it?

yeah it is all over the place
i dont want to change gravity in the whole engine, and i would have to do it all again when i update ue4. there are some important fixes coming in the next one.
im leaning towards a 0g level and using addforce, it doesnt seem to drop performance anything much.

You wouldn’t have to do it again if you were to adopt version control :wink: