Where does simulate physics communicate with the physX engine?

I need to find where the “Simulate Physics” on a characters capsule component hands off to the physX engine. I’ve already converted the character movement component to use my own custom gravity. But if simulate physics is toggled then the physX engine takes over correct? Where does this occur at? Does the physX engine take a vector and does this occur constantly throughout the simulation?

I wonder if you’re better off not using gravity at all but just applying a force in your chosen gravity direction at all times and switching that direction as your character changes their position. I’m assuming you’re doing a Prey style game where you can walk sideways on a wall or upside down on a ceiling sometimes.

I know I am not quite answering your question but I would try it this way if you don’t find a better solution.

I see what you’re saying, I looked and didn’t see an obvious place where the code was tugging on the character using the gravity value… Yeah that is confusing. I wish I had a better answer for you.

The character Movement Component is pretty big but I’ve gone through and modified everything that deals with this (or at least I believe). My character can walks on the walls and ceiling no problems, falls back to his relative down vector, and can collide, slide, crouch, swim, fly, etc… all with the system working. Where the problem comes in is when the default capsule component attached to the character class has its “Simulate Physics” toggled. At this point the character will fall only relative to the worlds “z”. It seems that during this period something else takes over and that’s the part I need to modify in the same way the character movement component is done.

CharacterMovementComponent, MovementComponent, PhysicsVolume, World, and WorldSettings all have GetGravityZ methods. Only CharacterMovementComponent appears to utilize the value fetched. What I would like to do is find where the capsule component falls when “simulate gravity” is toggled and modify the relevant classes GetGravityZ() methods to take the world location of this capsule component. This is all I need to fix the physics making the object fall only along Z.

Can someone offer a description of how the physX engine handles object once they are toggled “simulate physics”?

Okay I found that in PhysLevel.cpp there is a FVector “defaultGravity”. Changing this effects the gravity direction while “simulate physics” is toggled on. So now I need to figure out how to have each physics asset reference it’s location when calling this.

I believe physxScene holds most of the method that Convert ue4 structures to physX ones. PhysLevel has a setup physics tick method that sets the gravity direction for the scene. As far as I can tell each physics scene has one gravity direction. This seems problematic for point gravity.