How to change the gravity direction of an pawn ?

How to do that, or how to handle the gravity of that object with less intensity. :confused:

Hey Neongho!

I’m not sure how to handle the gravity direction, but you can change the gravity scale with ease.
In blueprints it’s in the component tab, under ‘CharacterMovement’, called ‘Gravity Scale’,
or you can access it in your character class using:



CharacterMovement->GravityScale = 0.5f;


Also, any other customisable factors about a character’s movement can be found here!
And anything else will be in the parent classes/links.

Hope this helps!

-Peace

I’m not at a development machine right now or I’d try myself, but does this snippet work as expected?



CharacterMovement->GravityScale = -1.0f;


Hey thanks loken and veovis for the ansawers, now i have one variable sorted, what about the direction one ? im sure there is one, i think developers did think big, and implemented a gravity direction control, for space based games.
" and still there’s a lot of different uses anyways ".

bump-

From what I can find UE4 only supports gravity along the Z axis right now (which you can customise under Project Settings > Physics > Default Gravity Z). For different behavior you might have to do the Physics yourself. Unless I overlooked another gravity setting somewhere that you can only access from C++.

From what I’ve seen gravity is either up or down (Tested -1.0f today, it definitely reverses gravity) but you have another option. Add a radial force actor and make the force a negative value. This would allow you to have basically point gravity. I haven’t found any built-in actors that would work for simulating a different gravity vector, but you should be able to look at the sources for the radial force actor and simplify it a bit if you need a different gravity vector.

Alternatively, if you need a single different gravity vector, but the whole project will use the same direction, you could simply build your level on its side. If Unreal 4 had portals like previous versions you could even have different areas with different gravity in the same level, which all looked to be seamless. The default skysphere would need to be tweaked/removed though.

Alright RPG hacker, i don’t think i will be implementing physics myself because with such a level i have of maths and " physics subject itself" it would take me … defintively some time.
I migth try this kind of radial force actor. One would just set the gravity to 0 and from there apply individualy with the tick function of every actor the radial force actor.
Off topic, maybe even off forums, does any engine support different gravity point ?

No, the radial force actor should do what you need, you shouldn’t need to tick anything else.

This is actually the best in-engine support I’ve seen for multiple gravity systems. Unity does have the ability to change the gravity as a Vector, but getting localized gravity meant iterating over everything in the area you wanted manually.

There is no easy way to change the direction of gravity, at least not for characters that have to stay upright.

Anyways, a somewhat easy workaround is to rotate the map around a player. Just build the map as blueprint and then rotate the actor (alternativley just attach everything to a parent after placing it, and then rotate the parent). This way the gravity is still z-up, but all physics related things kinda fake a change in gravity direction.

The next best solution is to rewrite everything to work with an arbitrary gravity vector, or alternatively wait for epic to implement it, since they have it on their roadmap :stuck_out_tongue:

Rotating the world disallows static lighting, which can cause performance problems.
You could use the 6dof tutorial from ue3, I suppose it will be pretty similair.

Also note that you can vote for things on the roadmap, so if you want an official multiple gravity source system in Unreal 4, go vote on this card. (You’ll need a Trello account I believe) EDIT: This card as well it appears.

Looks like the roadmap for gravity stuff is September, if that helps your decision making.