3
\$\begingroup\$

I am fairly new to unreal engine and I would like to know how to set custom gravity in a specific point or area instead of down. For example I do not want the gravity pull to be down but more to the center of my level (center plane not center point) and that gravity to only affect specific actors. Other actors will be affected by normal gravity or affected by no gravity at all.

How can I do this? (blueprints or c++)

\$\endgroup\$
3
\$\begingroup\$

I know they're planning to un-hardcode Gravity [Source: I'm a moderator on the official Unreal Engine forums, I know things ;)] but the best way is to either add force in the direction you want or set the player to "Flying" mode and push him about with Launch character / Add force.

This is the only way without altering source code (Until they un-hard code gravity).

Tl;Dr - Fake it for now, A fix will come eventually!

\$\endgroup\$
  • \$\begingroup\$ by eventually what is the anticipated time? cause I am only at the start of my game. This is not one of the urgencies but I thought I should so I could comprehend and have a solution ready when I need it. If it's not in three years then I can wait for it \$\endgroup\$ – John Demetriou Jul 28 '15 at 7:49
2
\$\begingroup\$

You can not change the direction of the built-in gravity, it always points to the negative z-axis. You can also not change the gravity for single actors, only globally. But why do you need that, you can always just increase the mass of your actor.

You can easily turn off gravity completely for any actor, just look for "gravity" in the blueprint options of that actor.

\$\endgroup\$
  • \$\begingroup\$ Well I need specific gravity let's say In a 3D world I want the gravity to be the center plane of the world, items above that plane to be dragged down and items below that plane to be dragged up. \$\endgroup\$ – John Demetriou Jul 26 '15 at 20:39
  • \$\begingroup\$ is there no way to do that? \$\endgroup\$ – John Demetriou Jul 27 '15 at 7:08
  • 1
    \$\begingroup\$ No, the z-axis gravity is hardcoded into the engine. You can of course write your own gravity code or change the engine code, but that will be one heck of a job. Look around the forums, some people played around with dynamic gravity, but the results are all glitchy and a lot of work. The gravity constraint really is one if UE4's weaknesses. \$\endgroup\$ – TheBrain Jul 27 '15 at 7:20
  • 1
    \$\begingroup\$ Maybe I should just disable gravity and write a specific force that draws the object towards the plane more or less \$\endgroup\$ – John Demetriou Jul 27 '15 at 7:39
1
\$\begingroup\$

I've been drifting through forums looking for what others have done for gravity solution as I'm working on centrifugal gravity in my work.

The first to counter global Z gravity to have the effect of a null gravity environment is simply add the game's gravity * delta time to Z movement while inside the zone. Then apply your own acceleration for the gravity you want.

In your situation you want to apply acceleration in the direction of your centre point.

At the moment I'm still trying to figure out how apply of Coriolis effect.

This is basic theory but it is all maths.

Hope it helps.

\$\endgroup\$
  • 1
    \$\begingroup\$ There is no such thing as "necro posting" on Stack Exchange :) \$\endgroup\$ – Vaillancourt Nov 15 '16 at 22:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.