SakeTami
Megan Fox
Megan Fox

patreon


Fake Gravity 2.0

So, previously I did a post about Metroid Prime style fake gravity. Basically, to get the best of both worlds of thumpy heavy gravity and good air control during platforming, you adjust the player's (and only the player's) gravity scale based on the state of their jump button. Neat stuff! Pop over here to read it.

Read it? Ok, good, now let's make it better.

Smoothing The Gravity Out

So there's really nothing wrong with that style of gravity, it's fine, but. It's abrupt, right? Seems like we could smooth it out. And we CAN.

Let me introduce to one of my favorite tools in Unreal: CURVES

This is a curve I use in gravity calcs. We're doing the same thing we did before, basically creating a temporary window during which we override only the character in question's gravity. We just vary it over time. Like this

That BaseGravityMultiplier there is just a curve variable, that contains the curve for the gravity override in question. Lifetime is a normalized 0-1 value that indicates how far along in the movement params override window you are.

The above curve there creates a heavy fall, wherein at the start of the window you experience regular gravity and then we smoothly ratchet that up to 3x. This kind of gravity's nice for giving you a quick pop-up and then a SLAM down. This is what you might want in, say, a character action game.

Most of my curves look like this though,

This one is 1/3rd gravity, done. This is just how you turn this upgraded system into something that acts more like the simple version I explained in the above-linked blog. You don't need to use the curves all the time, though you certainly can, just remember to make any looping gravity overrides such that they hold at time 0 until you release the loop, then it plays out to (specified length), so that you can treat your curve as the tailing-out of the effect. Or have it hold at 0.5 if you like, then you've got a nice intro too.

Now then, funny story: I don't actually use this in my current game!

Why I Dropped This

My current game is action-focused, relatively little platforming, and a ton of root-motion for the attacks. The situations where I was previously leveraging this tech to make a jump attack as floaty as I wanted it to be? Well, now I just, you know. Animate it! Turns out root motion isn't evil if you're both the animator and the designer, and doing it all in-engine. Makes it super fast to iterate on.

The further you are from a tightly animated game like that, the more this kinda gravity variance tech will be appealing. Platformers, lite action games, exploration games, hell probably even movement-focused games like Pseudoregalia that have a lot of action, odds are probable you'll want a more flexible system like this.

It's just I went combat-focused and want a lot of precise movements and hitframes, so I kinda need the root motion. You can make root motion play into flexible movement too, you just end up with something more like DMC in how it controls. Anyways, you can make that call for yourself. Both are good!

Why It Worked So Well Before

An understated element of why this worked so well for me was just that, well in my previous game where I was using this gravity tech: my guy had wings!

These wings pop out any time I extend a jump with a hold (AND have negative Z velocity), and they do an absolutely lovely job of contextualizing why you suddenly slow down. The underlying tech is the same, I just add a gravity modifier when you're holding the jump button down, which lowers your gravity, which gives you Metroid Prime Jumps, but- the wings made it feel natural.

Metroid Prime? It felt natural because you're first person, and don't have an external frame of reference. It feels natural for gravity to extend because you're holding a button, and immersed in the character, so it feels like You, so of course that happens. Also you can add sounds that add a PSSSSST gas/rocket booster whatever if you want.

Anyways, point is, if you go this route? It really helps to have something like this up your sleeve to contextualize the gravity shift. Though you probably only need to bother if you make the scalar difference substantial. Little differences? No need, play with it. Still let's imagine you're really amping it up, so:

First person, way easier, covered it above. Third? Spend a little time and think of something, anything, to put in here. It's a good place to put a little glider popout, opening wings, magical fairy pulls you up by the hair, whatever, get creative. If it's feeling weird, it's probably not that the gravity effect is wrong, just that you haven't added anything to visually contextualize it yet.


More Creators