How to stop a character mid jump then resume

Hello all,

I’m working on a character with both ground and air combat and for the air combat I want to be able to make my character stop in mid air to attack and then after the attack is finished fall to the ground. Currently I have it stopping in mid air by setting the z position of the Movement Component to where it was when the attack started on every frame. And this works for the most part, however when the attack ends and I stop setting the position my character goes straight to the ground. After debugging the issue I’ve found that it isn’t snapping but the velocity still seems to be updated. I’ve set the gravity, the mass, acceleration, and velocity to 0 while attacking and it still happens. Is it possible the Movement Component is still updating this even through all the values are 0?

If anyone has any different ideas to get my character to stop in mid air only while attacking and then fall I’m open to anything.

Thanks

Like with anything, there’s probably a lot of ways to do this, but you could try setting the Movement Mode to “Flying”;

(The “IsFalling” bool is to prevent it from executing on the ground)

The “Stop Movement Immediately” will stop the momentum of the initial jump. It might not be needed, depending on what you’re trying to do exactly. If you remove it, you’ll probably want to change your “Max Fly Speed”.

When it returns to “walking mode” it will drop the character to the ground as normal. I have it set to execute when I release the input, but you could also have an AnimNotify that triggers it at the end of an animation.

There is something you have to be careful of when using this method though, when you set the Movement Mode to “Flying”, it will stop registering things like jumping, gravity, and falling, so you’ll have to compensate for that in your animation blueprints. By default, your animation blueprint will think your character has landed and probably put it into a walking or landing/idle animation (depending on its current velocity), so you’ll need to override that, presumably with your attack animations.

You actually don’t need to call it every frame. Switching the movement mode to flying is only needed once and will remain that way until changed to something else.

That’s interesting then, because that means there must be something else in your project influencing your character. Maybe try implementing this in a new project, like a third person template, to see what happens.

The only other thing I can immediately think of off the top of my head is that maybe your attack animations have root motion that is moving your character? If your animations have root motion, maybe try disabling them to see what happens.

Thanks for the reply! The idea seems like it would work. But when I tried for some reason even in “Flying mode” the character still falls. I call Stop Movement Immediately and I think I can see one frame where the character stops moving. Calling this every frame while attacking doesn’t keep him in place however. I have the Max Fly Speed at 0 and it still falls. Is there any sort of other setup I need to enable flying other than setting Can Fly to true?

I just tried the idea in a spike project and it works there so it is something in my project that’s doing it. When I find what it is I’ll post it here. Thanks again, at least I have something I know works now.

Anytime, good luck.

Figured out the issue. When I made a new project and imported my content it worked. Which is great so thank you again. The issue (I think) was having starter content. When I remade the project I didn’t add it and it worked so that’s what I think it was. But it does work now!

could you show a print about how is your blueprint now please?

Sure, if I recall the issue was in the template of the project. Creating a new empty project fixed the issue. The first screenshot is of the update where I check to see if I am attacking in mid air, and if so set movement to flying.

And the second is for when I have detected that the combo is over and to resume falling.

77717-comboended.png

Thanks bro. And about the problem the PixelOmen told about?

“There is something you have to be careful of when using this method though, when you set the Movement Mode to “Flying”, it will stop registering things like jumping, gravity, and falling, so you’ll have to compensate for that in your animation blueprints. By default, your animation blueprint will think your character has landed and probably put it into a walking or landing/idle animation (depending on its current velocity), so you’ll need to override that, presumably with your attack animations.”

Did you solved it? I’m trying to do a movement just like yours. When I press Shift in the air the character stops and I can shoot if I want it. But while I’m flying in the air, the character still recieve inputs and do the animations. I would like to disable the input for all of them and enable when I release Shift button.

What I do is keep track of if I’m in the air and if if I’m currently attacking in mid air. Then I base my input on what I want to receive if I’m in the air with just a branch statement. I also assume that if the attacking in mid air bool is set then the character is still in mid air and my anim blueprint will treat it like I am.