Slow character down when mouse is near

Hi im creating a top down point and click game.
you can press and hold to move the character.

what im trying to do is slow the character down depending on how close the mouse is to the character.
so if you have it close the guy will walk and far away it will be running speed.

im quite new to blueprints so any help would be appreciated

i am just using the default top down character

You could multiply the speed depending on the distance the move-to-target/vector has to your char.

There is a function inside the Top down controller called Move to hit location which handles the click to move behavior. I’ve modified it to do what you’re going for.

Basically, you get the owned pawn’s location (that’s you) and subtract the location of the cursor. This gives you the number of units between the two (that’s the distance). I divide that number by 700 to make the number a small 0-2 float.*

*In the top down template, 1500 units is just about the furthest you can click, so 700 a little under half the units of the furthest you can click, which is why I chose that number for the division.

Then I clamp it to make sure we don’t get any numbers that are too big. I used .3 as my low number, which means the slowest you’ll move is around 30% speed and used 2 as the high number so you’ll be able to move twice as fast. (If you want to move three times as fast, I’d use 375 as the division number and set the clamp to 3 on the high end.)

Then we multiply that number by the default Walk speed (which is 600) and set the MaxWalkSpeed variable to the resulting number. (MaxWalkSpeed is in your character blueprint on the CharacterMovement component.)

Hopefully this makes sense. Feel free to ask if you’re fuzzy on anything. Otherwise, good luck!

■■■■ that just confuses me even more :stuck_out_tongue: whats that purple one in the top left?