Movement speed depend on cursor distance from character

Hello. I am working on TopDown template and I am solving a problem where I would like to use the mouse to change the speed of movement depending on the distance of the cursor and the character. The farther the cursor moves away from the character, the faster the character runs. I tried using the “trigger” using collision sphere and MouseBeginOver but there was a problem with the setup collision. Either the object did not pass through the wall or did not respond to mouseBeginOver.
Then I tried different ways to calculate the distance between cursor and character but it never worked properly. There was always a problem on one side of the axis where it had to be cursor further than on the other side.

I am try something like that

but didnt work perfectly especialy i have problem in diagonals.

If you’re using the same movement method as the template, you can do this:

Image from Gyazo

The template is placing a decal called Cursor to World at the line traced location. You can use it to find the distance from the decal (which is at cursor location) to the character and map range it.

The 2000 here is the max distance the cursor can be away from the character, beyond that the speed will not increase. The walk speed ranges from 0 to 1200, depending how far the cursor is from the character.

Super, thank you sir :slight_smile: I am looking for solution all day :smiley:

And if i want to make only 2 stages ?
only with speed 200 and 600 not
gradually because its little bit

This should work.