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\$

4 Answers 4

4
\$\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\$
2
  • \$\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\$ Commented Jul 28, 2015 at 7:49
  • \$\begingroup\$ Any news on this, seven years later? \$\endgroup\$
    – Sti
    Commented May 2, 2022 at 10:26
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\$
4
  • \$\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\$ Commented Jul 26, 2015 at 20:39
  • \$\begingroup\$ is there no way to do that? \$\endgroup\$ Commented Jul 27, 2015 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
    Commented Jul 27, 2015 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\$ Commented Jul 27, 2015 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
  • 1
    \$\begingroup\$ There is no such thing as "necro posting" on Stack Exchange :) \$\endgroup\$
    – Vaillancourt
    Commented Nov 15, 2016 at 22:11
1
\$\begingroup\$

This topic is old but I think this video may help future visitors. What you are trying to do is possible: it's called dynamic gravity. Check this video https://www.youtube.com/watch?v=kkq5En9sG8Y

\$\endgroup\$
1
  • 1
    \$\begingroup\$ This is currently a link-only answer: if the video link ever changes or becomes inaccessible from a certain region, then this won't help a future reader. Please edit your answer to include at least a rough summary of what you hope a future visitor will learn from the video, so that even if the link rots your answer can still help them. \$\endgroup\$
    – DMGregory
    Commented Jan 5, 2022 at 14:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .