x

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"

Best approach for different gravity

Hello,

We are working on a prototype that requires the player to be able to walk on planets, and float in space when not in range of the planets gravity field. This means the gravity should be calculated depending on the characters position in space (And offcourse any other object with physics assigned).

Now the way UE4 handles gravity is a float variable on the Z axis that is set to -1. This can be changed to +1 or 0.5 or something. Also this is set on starting the game, and is not changed during runtime, and also locked on the map, and not different for every player. This is obviously not what we want to use. We have to create a whole new way of calculating the gravity for each player individually.

Now I did some research, and also tried some things, and I came up with 2 solutions. Either I am going to ignore the whole UE4 gravity, and put everything in the world to my own gravity calculation. But this would mean I can also not use the basic character movement and have to write it all for my own.

Or I could throw away the way gravity is calculated in UE4, and change it to the way I want. But this means changing the way the engine it self handles gravity, and could also be a risky approach (I think).

Any tips how this could be achieved in the best possible way? The project is not in a hurry now, and before breaking apart anything I would like some tips, and maybe someone here has done this already and has some ideas how I could do this.

Thanks in advance

Product Version: Not Selected
Tags:
more ▼

asked Feb 17 '15 at 06:31 PM in C++ Programming

avatar image

SoulRyder
40 9 12 16

avatar image MickD777 Feb 17 '15 at 08:28 PM

You could always apply the gravity you want as an extra force on the actors. I'll look into it further but thats what popped in my head first.

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

I recently made a pull request that does this.

https://github.com/EpicGames/UnrealEngine/pull/1773

You can call SetWorldGravity from the Level Blueprint with a vector and gravity for everything in your world will change to that vector.

If you only want the characters gravity to change, you can call SetGravity on it. You will still need to calculate the vector you pass to it based on the characters position in space, but thats all. (You will also need to adjust the camera and input controls to work for non-Z only gravity)

more ▼

answered Nov 20 '15 at 07:39 AM

avatar image

glazed4444
16 1 2 3

avatar image SoulRyder Nov 20 '15 at 10:08 AM

Wow nice, initially I asked it for a small gamejam we did. But this could be helpfull for some future project :D Thanks for the answer!

avatar image glazed4444 Nov 20 '15 at 10:25 AM

No problem. After answering this, I did some more research and found this plugin https://forums.unrealengine.com/showthread.php?85022-Blueprint-C-Advanced-Templates-Tools-amp-Plugins (link to actual plugin on first post of that forum) that appears to do everything the pull request above does and a little more.

avatar image SoulRyder Nov 20 '15 at 11:09 AM

Thanks for the link! That is nice too :)

(comments are locked)
10|2000 characters needed characters left
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