Changing PhysX internal code

I wanted to know if its possible to edit the Unreal Engine 4 base Physx code.

I was planning to introduce few custom damping and force like features to it.
Applying force or changing the physics linear velocity directly is not giving the best results as from what I have tested, GPU calculation have a 1 frame delay before GPU values get updated.

Also, if later I want to run the game with physics sub-stepping, it wont be possible to do.

So has any one tried any similar method to make it work?

It sounds like you just need to make sure you’re applying your forces / velocities etc. before the physx simulation runs that frame. You can do that by setting the Tick Group of your object to TG_PrePhysics.

If you’re applying your changes in TG_DuringPhysics or TG_PostPhysics, then your changes won’t be integrated until the next frame.

There are still a few effects like gravity that still work.

e.g. I set the PhysicsLinearVelocity of the body to be 0 per tick, But the body moves down ever so slightly.
It works for the most part but its kind of not perfect.

Yeah it will move down, because you’re setting velocity - but that happens before the simulation runs, then PhysX is applying gravity. The way to get around that is to also disable gravity on the object (again, pre-simulation).