(tank controls) keeping forward orientation after releasing fwd button but turning

I have no idea how to make a short descriptive question about this. Essentially I have tank controls. W forward, S backward, a and d turn left right. With mouse look. Like world of tanks. My issue is that after I gather some speed holding w button I release the w button and then press either a or d. My character turns but keeps going straight which means it ends up sort of moonwalking sideways. How do I get the character to turn and move to that direction when neither w nor s is pressed?

Here are my movement and turning bp. Nothing fancy except long acceleration and deceleration times which are not shown here. And during those deceleration moments I’d like to steer the character with a/d buttons

For basic tank controls you could try something like this:

This accumulates the speed factor in a variable and then applies is constantly.

Image from Gyazo

Thanks for the response. The way I have set up my controls is that I’d need to hold w key to keep going forward. This also accelerates the character forwards until I reach max speed. Switching to speed based movement where w and s just increase and decrease the speed could be a solution but I sort of prefer the button holding because I need lots of small movements occasionally and the speed based system is a bit slow for that.

Thanks for the response. The way I
have set up my controls is that I’d
need to hold w key to keep going
forward. This also accelerates the
character forwards until I reach max
speed.

Makes sense.

It’s a bit unclear to me how the input is applied in your example. Technically, if you released forward input, the Pawn should stop immediately. Perhaps you’re using Floating Pawn Movement for this?

Do you apply something during Tick?

This is the complete moving setup at the moment:

It is hacky but I am currently redoing and the movement /rotation orientation issue was my first problem. I think I’ll just move all the forward/backwards movement nodes from the inputaxis to tick instead of trying to do the same thing in two places. Probably enough to just have a bool for the inputaxis and then in tick do the acceleration/deceleration based on that. I don’t have any good ideas for the main issue of this main question though. Here is what I tried earlier:

Obviously that example doesn’t work but I wonder if it is even the right idea to try to use the addMovementInput node for this?
I’d imagine the problem becomes easier to solve once I have moved the movement stuff to tick.

I think I’ll just move all the
forward/backwards movement nodes from
the inputaxis to tick instead of
trying to do the same thing in two
places.

Do note that the Input Axis is Ticking. It always spits out values, either what you’ve assigned or 0. If you look at my example, you’ll see that I’m utilising that 0 to keep moving even if nothing is pressed.

Perhaps that will inspire you.


But sure, you can use Inputs to generate values for Tick to use. It’s a like a mini AI / automation movement.

Also, you’re using character movement here which comes with its own set of rules and overrides a lot of physics. It can be a blessing and a curse at the same time.

Yeah I know how the tick works :). I am not sure how to get the character to move to new direction after I release the w button and start turning. It still rotates but goes straight. Like a car that only steers when I press the throttle.

I am not sure how to get the character
to move to new direction after I
release the w button and start
turning.

If you want to use the Character Movement Component and Add Movement Input, you need to keep applying that forward direction constantly for the Pawn to move, regardless of the Axis Input value.

I just can’t figure out how to do that without ending up in a situation where the character just keeps going forward at constant speed

So what is supposed to happen when I release Forward, we gradually slow down to 0?

This is what I have now and it doesn’t work:


The way it is works is that first I check if there is button input active for forward or backwards. False is when there is none and this is the scenario that is the issue here. Then it checks if the character is going forward or backwards. Dot product compared to forward vector should be positive for forward and negative for backwards.

Then there is a if clause that triggers if the speed is above 0.02x max walk speed. No need to “steer” when near 0 speed. After that a small 0.05 addMovementInput is added.

Issue is that the movement input either does nothing or just locks the forward speed so I need to press s to stop. Or w if going backwards.

Sorry, I missed this post. So what I’d want to happen is that when I release forward the speed slowly goes down to 0. That works pretty fine. But the issue is that after I release forward there is like 4 seconds before it stops from full speed. If during that time I press a or d to turn left or right the character turns but goes straight which means it ends up walking sideways. I’d want to steer the character with a and d so that it goes to the direction it is heading and not walk sideways. If I keep w or s pressed it works fine.