Download

Dynamic Gravity For character

Hey , I wanted to share this news with the community, I managed to build a Movement system that supports Dynamic Gravity for characters in any direction along with walking,falling and full multiplayer network support.

It is a custom Character movement built by extending and modifying the code of original UCharacterComponent of UE4 (Full source code aspect of UE4 Paid off :slight_smile: )

Here’s a demo (Pardon Low FPS old PC :frowning: )

A detailed description of whats happening:

We’re hopping around different platforms which have their own gravity fields , The character stands upright when it lands on a different gravity platform and can walk on it or jump etc.

1.when you are not in any gravity field you are free floating and moving with conservation of momentum.

2.The Wireframe boxes and sphere represent the gravity zones of objects.

3.When you are in a box the gravity points directly towards down direction of the box.

4.When you are inside sphere (The red ones) the gravity is acting towards center of the sphere.

5.The global world gravity of map is zero.

  1. The Movement component tries to correct player’s orientation to align with gravity when possible and set to do so (which enable walking on spherical objects)

**The Gravity Regions (Wireframe Boxes and spheres) **are their own actors separate from the solid meshes , Hence they can be attached to anything or whatever , they are purely gravity field. As such any kind of Gravity field with any shape or gravity distribution can be used.

Sphere Gravity Field
531f76d45c853c5b38ffe0b0010de18711cb1977.png

Box Gravity field (Red arrow represents Direction of gravity in the box)
ff5e4203484a181a261601fc4b863880.png

When you look at dark void and there are no shiny stuff around you can see the milky way and stars. The player standing upright when landing is a behavior written in the character class and not part of the movement component hence any kind of behavior can be written including falling down and then standing up instead of just turning straight up

This custom as a component for my own personal project Solar Frontier but I think this is much stable and flexible to be used anywhere and not just this particular project

At this moment only Walking and falling mode is supported , but other modes like swimming is rarely used in a dynamic gravity environment and can be added easily anyway

I don’t think anyone knows about my project solar frontier but just in case you want to see it here’s an old video :

For those who didn’t understood whats happening or want a better insight here’s a playable demo.

Press R to Reset your position if you are lost floating in space

Thats very cool! I like sci-fi projects and that looks like a very cool place to start. I’ve played around with some gravity functionality myself in the past but don’t believe it was multiplayer capable at all, nor allowed the character re-orient itself on different gravitational bodies. Nice work! Is Solar Frontier something you are doing for fun on your spare time alone or is it something of greater scale and scope? I’ve not heard of it before.

This is getting preeetty interesting, congratulations!

Hey thank’s man!

Well Solar Frontier is my personal project. You know that sad old story , we all want to make our own dream game but not everyone of us has resources to pull it off with the speed and quality of a studio. So yes I do want to this to turn into a full fledged game one day but right now I’m making the basic mechanics for it one step at a time while working as freelance programmer for other’s projects.

Its heavily inspired from Starlancer a classic space fighter combat game from 2000 I’m a big fan of that game, especially the execution and lively voice acting

I have a lot of ideas and plans for it but I am not making a exclusive thread and working silently until I have solid content to show :slight_smile:
Making hype without content is not my style :wink:

ok enough with boring you with my opinions

Now for the Dynamic Gravity it is an extension of the default CharacterMovement component. I was clueless at first like you but then after reading the code for a while I realised it was just basic vector maths everywhere. So now the work was simple but long since epic had hardcoded CharacterMovement assuming that the gravity is always down world Z , So I had to rewrite a lot of routines to use the vector I give as gravity instead of world gravity. Hopping around and editing 50+ functions in 2500 lines of code And that was about it. oh and I wrote reorienting character code in the character instead of movement component

It was an enlightening experience honestly , the whole CharacterMovement thing from epic is actually sort of manually simulated physics.

thanks man! :slight_smile:

I really like it. The video from first post is cool. :slight_smile:

Thanks man , you can actually play it by downloading the demo linked in the second post http://www.mediafire.com/download/a8tt6y1m3uj6n9f/GravityTest2.rar

dude that is crazy cool. 0.o

aye thanks mate!

This is very well done! Works better than I had pictured.

Ha! I admire your dedication – I’d poked around the code a long time ago hoping to just tweak a few vector calculations and quickly gave up when I began to see how many places it was hardcoded… too bad, I would have liked to walk around on these vast spinning things:

Nice soundtrack choice in your video btw :wink: Looking forward to seeing where you go with this!

Thanks , Currently its a part of my personal project but if I can polish it enough to a easily implementable and extensible form then I might release it on the marketplace. I’m currently holding it off from release because I’m not convinced that its ready to be used everywhere without limitations.

I’d need to write some proper interfaces so it can be plugged in any kind of project and stuff.