Hey everyone,
I'm having a problem with the Point & Click movement using Unity2D in the camera settings and the polygon collider as pathfinding method.
My problem: Whenever I click outside the NavMesh, the algorithm looks for the point on the mesh that is nearest to my click and sends the character there. Depending on the mesh, this might be okay, but if there actually is a point straight underneath the click, it would just feel better, if the character would move right there. I checked modern 2D adventure games, and almost every game works this way.
In the picture above, the white cross is the point where I click. The pathfinding algorithm then computes the point marked in blue as nearest point to the interaction and sends my character right there. However, I would like the character to move to the yellow point.
My questions:
What do you think? Is this behavior desirable? Would you expect the character to move to the blue or the yellow point? I found it very awkward, within this navmesh the character makes very little steps when you want him to move somewhere on the right side, because he is always getting caught at the edges of the navmesh.
Would be okay if there ways no way where he could go underneath the click though. And, as I'm assuming right now, only then.
But then... no one ever has had problem with this. Am I missing something? Am I doing something wrong? Would using a different pathfinding / camera setting solve my problem?
And finally, technically: I would probably edit the NavigationEngine_PolygonCollider class, specifically the GetPointsArray(...) method. There, at the very beginning, check if there is a NavMesh point straight underneath the interaction point, and if so, move the target right there. If not, just continue. Good idea? Different approaches?
Thanks for everyone's feedback!
Marcus
Comments
For me, i usually click the place where i want the character to move to anyway, so that would be on the navmesh.
You can change the movemnt so it only works when clicking on the navmesh.
Maybe this is something more of what you want?