Clicking outside of navmesh to have character travel towards mouse.

I’m stumbling here trying to figure out to get my character to move towards my mouse in the topdown example provided. If I click outside if my navmesh my character won’t move. Which is severely interrupting. Any chance anyone has built a solution for this?

I came across this issue here Why does clicking outside of NavMesh bounds in a click-to-move project make the player pawn attempt to move towards world origin? - UE4 AnswerHub

But it went mostly unanswered. I’m mostly just looking for my character to go to the edge of the navmesh when I click outside of it. I don’t want the character to leave it, just travel in the direction of the mouse.

I would greatly appreciate any help on this!

It might be an awful solution to the issue, but what I did when moving my character was to do a AIMoveTo 3 meters in front (towards the mouse click) of the character, even though the click was 16 meters in front of the character. Then when the target had moved a little while, with a delay (unless you had clicked again) I moved the character another 3 meters towards the mouse click.

So the character would move all the way until he got 3 m or closer to a place where is no path finding.

Another way to do it is to find the closest path finding to the mouse click.

I played with this for almost 3 hours today, I’m still kind of stumped here. I’m definitely still kickin some ideas around, but I have nothing solid yet…

How about doing multiple line traces(top down) from the click location back to the char. The line trace end point would be something slightly lower than the ground that the char is on. First hit would signify ground at the closest to the click location.

I might need a little hand holding to set up that line trace back to the character. I’ve only briefly read about line traces. Never actually used them yet. Any chance I could get some assistance with this method?

Thanks for the idea. I’ll make good friends with google tonight trying this out. :slight_smile:

Okay… so here’s what I figured out… (At least I think)… The problem lies with the “Simple Move to Location” Node. (maybe) lol…

I believe if it’s hit location under cursor is outside the Navmesh, it won’t move at all. It’s also SUPER easy to replicate this…

1: create topdown game
2: Create new level with landscape
3: Make a small navmesh volume
4: Click the landscape where you know you don’t have nav and watch nothing happen… lol

Even though you want the character to stay in your navmesh, he still won’t go towards your click.

Problem I’m now having, is how to get my character to move “TOWARDS” the hit location, but still stay in Navmesh…

I’ve noticed as well, that if I place a navmesh volume way off in the distance, it works as intended. My character will walk towards my click location and stay in the navmesh volume he’s currently in just fine… So the hit result has to be within a navmesh volume. Trouble is… How do I bypass this check for my character?

Something like this?






More like If I click Outside of the navmesh. I’m currently at work at the moment, so I can’t test your method, but I’m definitely excited to see if it works in my case.

If my character was standing on the blue circle, and I click anywhere outside of the navmesh, he won’t move.

Ideally, I’d really like him to move to the edge of the navmesh in the direction towards my mouse click.

So, if he was starting at the blue circle, and you click outside of the navigation area, I’d like him to walk towards the black circle, and stop at the edge of the walkway there.

It’s super annyoing to have a character NOT move when you miss the navigation mesh… lol.

The example that i have provided allows basic use case where you can click on the edge and get the closest based on the line trace. It shouldnt be an issue from blue circle to black circle. However, it would fail at the black circle(from the stairs start point) as it was out of the line trace condition except to move a little to the edge, rather than to the actual closest point (perpendicular) in the nav mesh.

To get accurate results from the navmesh would require navpoly which i believed only achievable via c++ (i could be wrong in this though). Hope more people with experience in navigation could chip in their knowledge.

So, I copied this example down to a T… I unfortunately don’t get the same results as you. In fact, my character doesn’t move at all. I could see the debugging intersections though, but I’m very curious as to why mine didn’t work. Could it be because I was in the topdown game? Different mouse locations or something? I played with it quite a bit, but couldn’t get him to move. Any idea what could be different?

Okay, so I made a thirdpersoncharacter example, and I still ended up with nothing. I move one time, and only in a forward direction. Regardless of where I click, I get the same results. I triple checked everything, and still don’t have a working method for this, as I can’t seem to get your example working. I copied everything down to even the same colors you used… I then wen’t back to google for other results, but it appears this question has gone unanswered in other times it’s been brought up. I did manage to find a solve for it in C++, but I find it hard to believe it can’t be answered in BPs.

Anyways, I just figured I’d update this with my progress… Which has definitely not been great. I’ll keep at it though… It’s becoming a vendetta at this point… lol. Thank you very much for the help so far though. It’s a shame I can’t seem to replicate your results. These forums are always helpful!

Not sure what is wrong though. The blueprint was the exact that i have used to path when clicking outside of the nav mesh. It will not work for “within the nav mesh” and that would require some modification to the blueprint logic. Hope you can resolve this. Have fun!

Bump? Still trying to get a fix for this. I created a question on Unreal answers as well with no luck. Is there a way to do this without Navmesh?