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"

How can I change the direction of gravity on player input?

I'm currently working on a project that aims to have gravity change during game play, which will affect the players and assets in the environment. For a proof of concept I would like to demonstrate the change in gravity by allowing the player to toggle the orientation of gravity with a key press. In theory I can understand how this should work, but sadly I am not a programmer in any sense. I am an artist and level designer. Any help would be greatly appreciated, as I'm willing to expand my horizons and learn whatever is necessary to get this working properly.

Product Version: UE 4.19
more ▼

asked Jun 21 '18 at 09:56 PM in Blueprint Scripting

avatar image

Celestial Wind
1 1 1

avatar image ThompsonN13 Jun 21 '18 at 10:12 PM

there is a few potential issues here. first is if you want to create directions for gravity other than up and down that can be a little more complex but can be done. however if your looking to make a planet thats another story entirely. the second issue is that you need to be able to define which actors to affect when changing the gravity, for example you probably dont want to affect the ground or major structures. this can be solved by using tags though which should help (also gravity should only affect things set to moveable). the last issue is that getting the actors, changing the values, and running physics on them all won't be cheap so you may not get very good performance.

now i dont think there is a way to actually change the world gravity via blueprint but there is probably a was via C++. this link discusses something similar.

avatar image Celestial Wind Jun 22 '18 at 03:48 AM

Primarily I would like to focus on Up and Down being the only gravity vectors to be affected. And I agree, having only the actors that I want affected to move is very important. A defining feature of the project has to do with pathways, and obstacles changing for the players based on specific objects moving when gravity flips. I also understand that having so much change at once can be very taxing, so It's my intention to keep the amount of moving objects to a reasonable amount so that it runs smoothly.

Believe me every little bit helps, so thank you for your input.

avatar image rklsImmersion Jun 22 '18 at 03:01 AM

There's also the issue of making a resting state for objects (I might be wrong on this) because you'd want to add velocity to each object every tick, but make sure you're not adding velocity when the position the gravity moves them hasn't changed.

avatar image Celestial Wind Jun 22 '18 at 03:49 AM

This is something I have considered as well, though I'm not sure how to circumnavigate it. If i'm able to directly affect gravity somehow I don't think this should be an issue, however using forces as fake gravity seems like it would cause this problem.

avatar image ThompsonN13 Jun 22 '18 at 01:53 PM

to change gravity for characters you just need to get their movement component and change the gravity scale. for other actors im not really sure how you could change the gravity at runtime. its not really something ive pursued and most answers ive seen say to use C++.

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

0 answers: sort voted first
Be the first one to answer this question
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