How to limit distance of movement?

I started with top down template. As you know char moves to the place of click.
How i can limit the distance of movement? So char will stop after distance X, no matter where mouse’s click was done.

  • Make a float variable with the Max Distance that you need.
  • Then before move character or assign next location, get the current location of your character and substract the location where clicked to get the current distance to that point.
  • Compare that result with you Max Distance Variable and make a boolean if it is greater than, it will can’t move, if is less than, it will move.

hope this help you