Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Can I change the gravity direction?

I know that I can invert the gravity to a negative value but what if I wanted it to point forward or backwards, left/ right? Also is there a way to do this in Blue Print?

Product Version: Not Selected
more ▼

asked May 13 '14 at 03:42 PM in Blueprint Scripting

avatar image

966 143 150 390

avatar image Sam Kushner May 13 '14 at 06:13 PM

Hello Thumper,

What exactly are you trying to accomplish? Are you trying to change the gravity for the Player Character, a certain actor, or all actors in the level?



avatar image Thumper May 13 '14 at 06:34 PM

Well I've looked around looking for a blue print solution to creating inverted point gravity. So, in stead of gravitating toward a point like a planet you would repel from it. Imagine a hollowed out world where you can run around the inside of a sphere. This looks impossible through blue print only. But maybe there is trick. First I need to figure out how to point gravity in a specific direction. Currently the only access I see is in the character movement component. Where gravity z can be valued to a positive or negative. I was hoping for more of a vector or direction. Now it's got me thinking of crazy super hacks that I know will only cause serious headache down the road.

avatar image Thumper May 13 '14 at 06:40 PM

Rotating the world around the player is extreme, plus there's no way to get a navmesh to produce on the walls or ceiling that I know of. So the navmesh would have to create dynamically on the fly (which I've read is possible to do but sounds scary considering the scale of my navmesh requirements).

avatar image Zielak May 13 '14 at 06:45 PM

Check my other answer to see how I overriden standard gravity. Vector3 is available but you might want to do some more math to figure out how to make player walk "inside the sphere". Maybe figure out the direction from the center of sphere towards a player position and add that as linear force on character. Then you would need to rotate character accordingly.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

I have done that by overriding UE4's gravity and creating my own. How?

I have certain stuff in my game that I want them to react on directional gravity, all of them are child of my "Obstacle" blueprint. This can be done in other ways in your case but I'll show you how I did it :) This "parent class" has one Vector3 variable "Force" and one colider with one value changed - Physics -> "Enable Physics" turned off (you need to click the small arrow down to unfold advanced settings if you can't see it). That prevents an object from being affected by standard one-value ZGravity of UE4. Of course "Simulate Physics" mustbe checked for the rest of physics simulation to work.

Next, in the events graph just run "SetPhysicsLinearVelocity" function every tick, so you can easily manipulate that value in the runtime:

alt text

Using this method you can try setting linear velocity to a variable in the Level Scope, so all object share the same value. Hope that helps!

fake-gravity.png (83.6 kB)
more ▼

answered May 13 '14 at 06:31 PM

avatar image

235 8 14 18

avatar image Thumper May 13 '14 at 06:46 PM

This is something I've been considering. So you're saying to use forces to drive them in the direction instead of gravity? I think this is a possibility.

avatar image Zielak May 13 '14 at 06:59 PM

Yup, It's fake gravity indeed. I couldn't find any other proper way of doing this. UE4 doesn't seems to provide gravity as vector.

avatar image Neomex Jun 17 '14 at 09:55 AM

Can physics objects sleep this way? Or are they simulated all the time?

avatar image Thumper Jun 17 '14 at 01:16 PM

I tried doing this method but I ran into issues with getting the physics objects to not freak out during most other situations. Instead now I'm just programming the way the Character Movement Component uses gravity (modifying the evaluations/ velocities to use the character capsules Up Vector instead of the world "Z" axis). It's a bit of work but I'm already seeing the advantages - one big one being that I can keep the Character Movement Component with all it's robustness.

avatar image Zielak Jun 18 '14 at 10:43 AM

That is a good question. I'll remember to test it...

avatar image Sam Kushner Jun 18 '14 at 02:03 PM

Hello All,

This is a very popular subject that currently has no built in solution in UE4 to support gravity in any other direction that -Z. The possibilities are endless with direct access to the source code though!

There is a very interesting post on the forums https://forums.unrealengine.com/showthread.php?6592-Unreal-Z-axis-independent-gravity with someone making great improvements on his own project. He also raises good points about the different types of gravity being vector gravity volumes, point gravity, and inverse point gravity.

Good luck!


(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question