How to make a character to NOT stop moving in direction until I press the opposite button?

Sorry for the delay - had to wait 12 hours before I could post again.



I couldn’t get either of these to work properly…

Sorry if my response wasn’t clear, I’ll try again:

What I meant there was that you should not handle the the increase / decrease logic after the Event Tick node. You should only update your variable named “Flying Speed” by plugging it into the “Set Max Fly Speed” node as it is, without increasing or decreasing.

When it comes to handling the acceleration, you should keep increasing your variable for the duration of the input that you use to move the character forward. You could have an input action for the forward movement and plug the incrementation logic after the “ongoing” pin of the input action node. To make things easier, please consider using such input actions for forward and backward movements. Once you have those, plug in a really short delay node to the “ongoing” pin of your forward movement input action. After that, place the “++” node after the delay node and insert your variable to the “++” node’s input pin. Do the same for the backward movement input action but this time, replace the “++” node with the “- -” node.

I could also explain what to do to make it work for your existing input action, but let’s first succeed this approach and move on with that if it’s necessary.

Thank you.

I have now put the ++ (int) after the event tick (after the add movement input) with the result being that the object moves straight away when I hit the play button. When I hold the opposite button, is stops moving. However - there is no acceleration when pressing the button. The object still accelerates automatically?

I think there’s a communication problem. Please read my replies carefully. There’s nothing more I can say, you can achieve your goal by reading my already existing responses.

Thanks for all your help and apologies for not understanding.

I think will have to try and find an alternate way to achieve this.
I will post an update once I figure out a differerent way.

I’ve sent you a visualization via private messages. I see your last activity (your edit) was later than my message and it’s view count is still 1 (which is me), so I assume you’re not aware of the existence of that. You don’t need to search for a different way. If you read my explanations carefully or check out my visualization, you will be able to solve your issue :blush:

With help from @VisAgilis, some more research and a help from a friend; the original third person blueprint has been replaced with this:

This is working okay apart from not being able to control the deceleration.
I tried manupilating the brake deceleration as advised by @SupportiveEntity, but changing the value doesn’t seem to make any difference? What is strange, is that playing with the max acceleration or max fly speed does make a difference.

I’ve tried changing both flying and walk in different combinations and I’m not sure what I’m doing wrong.

Okay - the solution is this:

image

By changing the interp speed, both acceleration and deceleration are effected.

Luckily you posted while I was on PC.

No need for a finterp, it’s just this:

(btw i finally got to test it myself and yeah you need to use the trigger pin instead of the ongoing)

The result:

Switch on string?!
image

I will try this. Thanks a lot!

How are you connecting this?

Max Walk Speed is a preset variable inside the character movement component. You can get it by dragging out the character movement’s output pin, releasing it on an empty space, and typing in “max walk speed” to the menu that pops up.

Note that the blueprint code that I provided was only for the demonstration of the acceleration logic you wanted. It doesn’t include the parts where you handle the automatic movement, or the logic to accelerate during backwards movement. I thought this would suffice but do you need those parts as well?

GIVE ME EVERYTHING!!! :rofl: :rofl: :rofl:

Here you go :innocent:

Thanks

I can’t seem to get this to work. The object doesn’t move forward?

AHH SORRY!

I forgot to put the numbers in!

This works great! However, when I decelerate to go the opposite direction, the object accelerates going forward again instead backwards?

Am I supposed to create a separate ‘backwards’ input for this?

Keeping all the additional info that I’ve provided here, but check the very bottom to see the fix that you need to apply


First, check your action values by printing them out to see if they give the expected results.

For reference, here’s the outcome of my first blueprint code:

  • Acceleration default value: 5


If your character doesn’t rotate to the direction of the movement, add this to your code:

  • Mov Direc’s default value is (x = 1, y = 0, z = 0) but depends on your orientation. You can also just set it to be your character’s forward vector after the Event Begin Play node to be safe.
  • Mov Direc should be plugged into the “world direction” pin of the “Add Movement Input” node instead of the character’s forward vector in this case.

And here’s the outcome of the blueprint code that’s adjusted to work with a character that doesn’t orient it’s rotation to the direciton of the movement:


If you still can’t figure it out, create a new project by using the third person template like I did here, and implement my blueprint code there. Maybe you can see what else is different.


Your Fix

Okay found where your poblem is. You need to have these bindings:


Oh and one more thing, if you want the character to keep moving forward until it’s speed drops down to 0, and only then change it’s direction to go backwards, you can simply replace the Action Value Y (though might be different in your case) with this:

(Note that we used the same IA_Move node twice. The one that triggers my blueprint code an the one handles the bindings are not in the same execution chain. So do not replace the Action Value Y with the code above for the acceleration logic. Just replace the Action Value Y pin of the input action node that executes those two Add Movement Input nodes one after another.)

And here’s the outcome of the adjustment:

(The character orients it’s rotation to the movement direction in this demonstration. So do not apply the code which includes the custom movement vector (Mov Direc) in order for this to work)

Thank you very much for your patience. I tried to recreate your blueprint. Holding W key makes the object go forward which is great. Holding ‘S’ decelerates the object which also works great, but when you are still holding the ‘S’ key, the object still accelerates forward again. I’ve double checked, but I have missed something?

I think your character does orient it’s rotation to the direction of the movement. Like I’ve stated here, you shouldn’t have added that part if that’s your case.

I’ve also asked you to move our conversation to another platform if you had additional questions from the private messages, which you saw. Looking at the 40 message count under this single topic, which were mostly posted by only two of us, I feel like this topic has turned into a casual chat between us which shouldn’t belong in the forum (though i am also to blame here since I didn’t start providing code from the very beginning) so if the issue persists, please consider getting in touch with me via the message I’ve sent yesterday.