How to create custom gravity and physics

hello all,
i want to change the engine code to create a world where everyone has different gravity. it should include different down direction (for cameras and characters) different gravity directions. different definition of where he can walk.
i am well aware that it is not a simple task.
i hope you can help me with some information of where are those physics calculations are located and if there is some sort of helpfull tutorials that will help me learn the code around this.
thanks you for every piece of information :slight_smile:
.

#Config/DefaultEngine.ini

[/Script/Engine.PhysicsSettings]
DefaultGravityZ=0

You can set the world gravity to 0

and then implement your own gravity any way you want :slight_smile:

Something like

const float GravityMagnitude = 2000;
//for all components in the world
for(TObjectIterator<UPrimitiveComponent> Itr; Itr; ++Itr)
{
 if(!Itr->IsValidLowLevel()) 
{
   continue;
 }
  Itr->AddForce(FVector(0,0,-1) * GravityMagnitude); //this would be straight down again, normal gravity
}

or you can pick components of certain actors and apply gravity differently as you are wanting to do

My example code shows you how to do normal gravity simply for ease of understanding, you could flip gravity by using FVector(0,0,1)

Rama

tbh im trying to avoid this way i want to modify the engine to include this as a real option so im reading enough code to understand what i need to change. but thank you.

I realize this is extremely old but I made a pull request that does this.

You can simply call SetWorldGravity from the Level Blueprint and actors affected by gravity will change.

If you want characters to have different gravity you can set their custom gravity to something else.