How can I rotate character's velocity with the direction it's direction while in air?

I want to allow my character to turn a corner while in air (+ or - 90 degrees based on ‘Desired Rotation’). Currently, the character turns but keeps moving in the same direction it was before the turn, hits a wall, and then starts accelerating in the direction is the character is facing. I want to prevent the bolded part by ‘turning’ the velocity vector to match the turned character. I’ve attached the code and a graphic demonstrating what I’m going for and what’s currently happening. To be clear, it works perfectly on the ground. How can I do this?

I already tried setting the “Air Control” to 1 before the turn and lowering it again after the turn, same results.

How are you “moving” the character? Is this a flying pawn template? Is this a walking character? Right now it looks like you are literally just rotating the “mesh” not the direction of movement. You need to change the player’s velocity vector so if there is projectile movement you need to change the velocity variable for that. If it is walking you can use things like “get forward vector”.

Yes, it is a walking character. How can I rotate the velocity vector the proper amount? Thank you

I still don’t understand this whole movement mechanic for your character. It is a “walking” character that you want to be able to “turn while in the air”. So those are very different movement mechanics. One is “flight” one is “walking”. How is your character even in the air long enough for you to Lerp through a rotation? I don’t understand please clarify this mechanic. None of what you are describing is compatible with the generic FPS or TPS template as far as I know.

I am not familiar with that tutorial so you will have to give me some screen shots of how the player actually “moves”. Show me the “Add Movement Input” script, and the components panel so I can see what kind of “movement” it is using.

I started with the third person endless runner tutorial. The character accelerates forward automatically using “Add Movement Input” up to a max speed. The game gets very fast paced and includes platforms that drop down, so the character can jump and be in air for a long distance. Currently as you said, the mesh turns but the character keep moving in the same direction, so it’ll turn the mesh away from a wall but keep moving toward it and crash into it, ruining the pace of the game (when the character is in the air, it works fine on ground). I’ve been trying to solve this for a long time so I’d really appreciate any help.

249304-screen-shot-2018-08-03-at-123640-am.png

The pin at the top right goes to some code to handle swipes on mobile, which I don’t think is relevant, and the code at the bottom has to do with tilt controls on mobile.
Pin at bottom right leads to another ‘add movement input’ that has right vector as direction.

Umm…many things wrong here.

  1. Never use tick with a cast node
  2. Don’t even know why you are casting to game mode to being with, you don’t use anything from that cast node, it is completely irrelevant in this line of code
  3. You are setting player movement to “falling” if the player is “falling” which every time the player is in the air this is technically the case. The “falling” movement has no ability to change direction as far as I know, you would need something like “flying” for that
  4. “Turn Corner” just rotates the mesh and in “falling” mode I am not sure that is even relevant for actually changing the “forward” vector since the “forward” vector in a fall would be “down”
  5. I don’t think this will work with “falling” movement, “falling” implies you have no control and gravity takes over, you want control you should be “flying” and script logic from that

On a side note, that screen shot is not very good, can’t enlarge and you are hovered over something so the execution pins are not lit up, very hard to see where things are going

Can you maybe use “Launch character” with the “override speed” ticked? You can set the launch velocity depending on the character rotation and initial velocity. It’s hard to judge all your mechanics though.

Set the air control values for the character movement to allow you to move in the air.

Thanks for the suggestion, tried this already though. Didn’t change the behavior.

Thanks, while Launch didn’t exactly work, it inspired the solution I found.

Thanks for the catch on the cast, it was a remnant of a piece of code I was using for testing purposes that I recently took out, but even then it didn’t make sense to use it on tick. The solution I found for the problem is below, if you’re interested.

This solution works, for anyone who may need it in the future.

249437-screen-shot-2018-08-04-at-124646-pm.png

Hello, try this :

Go in your class default and UnCheck “UseControllerRotationYaw”, then go in your CharacterMovement Component and UnCheck “UseControllerDesiredRotation”.
Then, in your CharacterMovement Component Check “UseControllerDesiredRotation” and put in “RotationRate” X:360, Y:360, Z:360. This will make your character follow his velocity.

You may need to just increase the values of the air control variables. I’m not on my dev PC, but, it’s in the Character Movement Component. Increase the “Air Control” from 0 to 1 and then increase as well the “Air Boost Multiplier.” You may also want to increase the “Air Braking” (I think that’s the variable name?) so he’s less “drifty” in the air.

Keep in mind, these controls only work as long as your giving vales in the “Add Movement Input” node. Otherwise, Unreal will think the character is in air but “decelerating” since no “forward” movement input is given.

Hope this helps!

What is that node?