Download

Falling with a different gravity

Hello
I’m trying tomake a game where it is possible for the player to switch the gravity when pushing a button. The way I do this is by changing the gravity scale.
Knipsel.PNG
The only problem I’m having is that the player is that the boolean Isfalling of the character movement component is still true eventhough it should be false since he is running on the ceiling instead of the floor now.
Knipsel.PNG
As you see in the picture it’s still falling.
Does anybody know how to change this?
Thank you!

Maybe you could make a custom check by adding a small collision box below the character’s legs, and if it overlaps with something, it means it touches the ground. Not sure how well it’s gonna work tho

Well, I did that but I still have that same problem because the character movement component keeps checking if I’m falling or not, Is there a way to make the movement component check the boolean I made instead of the Isfalling one?
Knipsel.PNG
Knipsel.PNG

I assume you mean the animation? You should check the animation blueprint of the character.

No, I mean, My character doesn’t want to fall when I switch the gravity in the first image I’ve send, Because the character movement component still thinks the character is on the ground. And in the second image it still thinks it’s falling which it isn’t.
Knipsel.PNG
974b4a630ecd05c9fda3c9184dd59c972f153731.png

Oh, I am sorry I am not sure about that. I’ve never worked with Gravity Scale before.

My solution is as follows:

Create a new Pawn class that isn’t a Character class. Set up your blueprint to control like a character, but with your own values. That way, you can control everything.

Well, The problem I’m having is that I don’t really know how I can add movement into the pawn without using a floatingpawnmovement component. And I don’t know how you can add gravity with a floating pawn movement.

For the motion: what you can do is lock the yaw of your character to the mouse (and maybe the roll too), and use either an “Add Force” to a physics object or a “Set World Location” with offsets running on an EventTick (note that I never used any templates so I don’t know how the templates work by default) and then having the animation sync up to the local velocity of your pawn.

To add gravity to any object whatsoever, as long as it’s physics enabled (and even then maybe it doesn’t need to), a “Add Force” running on a EventTick with the vector defining the direction of “down” has shown to work for me. You can even increase/decrease gravity that way.