Changing movement modes - resetting yaw/pitch and keeping velocity

Currently swapping movement modes between fly and walk with a key press. I’ve copied over the entire movement mode of the Flying blueprint feature and tossed it into the ThirdPersonCharacter blueprint. I have a few branches set from key presses, which tells it to either move forward on the ground if walking, or pitch down if in flight.

It works almost perfectly. With a key press I’m flying like superman or an airplane, and then walking around back on the ground.

However I’ve come to a problem. When swapping back to the walking movement mode, my character stops mid-air and falls back to the ground. I’m trying to have him retain his speed and slow down over a few seconds, but I’m at a bit of a loss where to begin.

The other problem is that he’s keeping the air rotation and then runs along the ground at an angle. He can be almost belly down, horizontal with the ground while flying, switch back, and then keep that rotation while in walking mode.

I feel like I’m just unsure of which commands to use, I’ve tried using Event OnMovementModeChanged, unsuccessfully.

I’m not sure where the problem is, so I’ve tossed in a bunch of screenshots. It’s essentially just the Flight game blueprint added to third person.

If you can guide me in any direction, it would be greatly appreciated.

Hello @skobes,

For keeping the character velocity, I would store the velocity of the character movement component in a local variable just before you make the transition from air to ground. Kind of like the picture below.

52140-velchange+1.png

Next I would take this stored velocity and add it back to the character right after you make your transition from flying to walking.

52151-velchange+2.png

This should preserve your velocity without any weird hitches.

Now to rotate your character so that its you vector is (0, 0, 1) as you transition to from flight mode to walking mode, you will want to use the following code below. This code just sets the rotation to its previous rotation ignoring the Pitch and Roll of the object.

52152-velchange+3.png

I hope this answer helps,

Farshooter

Hmm… That’s weird in my test it worked without a hitch. Could you post of picture of your code when you switch from flying to walking?

The rotation part worked perfectly. I never knew I could right click and split the node into the separate axis, that’s what I had been looking to do. So thank you!

However the velocity didn’t seem to work.


This is what I have.

I tried your setup and found that it was definitely preserving some velocity. It seems like it would slow down though after the switch. This most likely is setting in the character movement controller.

Another technique you can try is to use the add impulse node instead of setting the velocity. This technique will physically accelerate the object. Check out the code below.

Side Note: You may have to tweak the scale of the velocity to get your desired behavior. I found that checking the “Velocity Change” field gives the character a nice boost when switching at fast speeds. This may be what you are looking for.

Farshooter

I think something else is affecting this then. I’ve tried doing this again, and also tried that exact add impulse, yet there’s still zero movement once I switch movement modes. I just drop like a rock from the sky.

Switch to Falling instead of Walking?