Sphere With Gravity

Hello all.

I am new to UE4, but not new to programming. I am playing around with the flying template. I have added two sphere, and am wondering how one would go about disabling gravity in the game, but having gravity be on the sphere - like a planet.

If anybody has any links to something that could help it would be great.

Hi there,

Gravity in the engine works in a way that assumes the world is “flat”, so gravity always moves in a single direction. if you want to make it work for a spherical object, the best way I can think of would be to create a radial force positioned at the centre of your sphere. Normally the force would push outwards, but if you put in a negative value it will suck objects toward it, just like gravity of a planet pulls objects towards ints centre.

go into the project settings and turn off gravity. You could also go as far as working out the correct gravity for each planet my multiplying it by its mass, or its overall volume.

I hope that helps a little…

I saw a point gravity example in the Content Examples under the Effects level. Not sure if it is only for effects, but it may give you some insight.

Thanks all. I will take a look at point gravity, and also I think it’s a neat idea to do the radial force in the center.

I am new to UE4, so it’s taking me some time to figure all this out.