Click To Move Straight

I’m trying to make the character move in a straight line (no pathfinding), but SimpleMoveToLocation uses pathfinding and I didn’t want to make a AI Controller tunnel to complicate the project later on.

I’ve tried copying over the source code and changing it to have bUsePathfinding false, but since it still expected a path it didn’t work. The only way I’ve gotten this to work is having it move the character using a normal vector each tick - I believe this is super inefficient and I’m expecting there is a way to move in straight lines that doesn’t include workarounds.

I’ve been testing everything in the top-down template.. Also, this would need to support multiplayer.

Hey @TKAsDaddy how are you??

I used the top-down template for this test, and the best thing I found is this:

  1. You can use a modified version of the “Follow” function (BP_TopDownController) from the template:


    I added a “bMovementAllowed” boolean to restrict movement if the character is alreeady on the destination. Making it “false” when the player reaches its goal.

  2. You need to use the base “GetLocationUnderCursor” function (BP_TopDownController) from the template:

  3. When you click, you get the clicked location and store it, then set the “bMovementAllowed” to true, so the tick is allowed, and then call the “Follow” function every tick:

With this, your character will move in a straight line without any pathfinding, and you will not calculate anything inside the “Follow” function if “bMovementAllowed” is false, not spending resources on it!

Hope this helps you! Let me know if you need more help!