I am trying to Change the Gravity of Character Movement Component As Right now it only points in -Z, I tired Rotating the Character Actor but it still falls in -Z Axis, which upon looking at Source Code it seems the PhysFalling Function is the one that handles the gravity and falling state.
It has a local Gravity Variable that Sets the Gravity in Z axis (Gravity = FVector(0.0f, 0.0f, GetGravityZ())
I don’t want to Change the source code, well I can’t and I downloaded the engine from Launcher. Is there any other way I can do this by Extended my own Character Movement Component from the out of box one?
Yeah I am looking to override the C++ code, basically make my own Character Movement Component that derives from the base Character Movement Component.
The Problem is that the PhysFalling Function is too complicated, its about more than 300 lines. If I override it I will have to call it’s super function, sadly the base function set the gravity direction locally and calls newFallVelocity Function and there is no way I can change that in the derived class.
Yes, the Character subsystem in Unreal is fairly hard-coded, and not structured with further extension as the top concern. A friend had a similar problem when trying to implement a “round” planet – the Character really just wants “up” to be Z.
It may be that your best option is to copy-and-paste the Character and CharacterMovementComponent classes out of the engine and into your own MyCharacter and MyCharacterMovementComponent classes, and then go from there.
There’s nothing at all preventing you from overriding ApplyDownwardForce() where the Gravity is set as you said, or NewFallVelocity().
Now, what I’d probably start with, is copying the entire PhysFalling into my own new custom Physics function, and mod it to handle the possible falling directions where gravity can go that it doesn’t now.
There is a MOVE_Custom mode, which calls PhysCustom(), with CustomMovementMode set to whatever uint8 you set it to. You can make your own enum, like EMovementMode, that defines various modes, if you’d like, then in PhysCustom() do a switch(CustomMovementMode) to handle your own gravity modes.
Thanks, I feel like I achieved something following your and jwatte’s advice, Now when I jump i.e when the character is not on ground it starts moving towards the -y Axis instead of -Z Axis.
The problem now is the Character Still does the Ground Check In Z axis even If I rotate the Character sideways it still checks for ground in Z. Which Function should I override to change the Ground Check Detection, I didn’t have much time to look at it but I did found some HitResult Variables but nothing much.