My problem
When i click outside of the default NavMesh my player doesn't walk to the closest point inside the NavMesh. When i click again on the exact same spot my player walks back, when i click again he walks back again. Basically he keeps walking back and forth.
What i except
When clicking outside of the NavMesh the player walks to the closest point inside the NavMesh. When clicking again on the exact same spot i except the player to do nothing as it is already on the closest spot inside the NavMesh.
Imgur showing what happens
What i tried
No matter what I try this problem keeps persisting, I must be missing something.
Extra info
Unity version: 2019.3.7f1
AC verion: v1.71.8
Pathfinding method: Polygon Collider
Movement method: Point And Click
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Welcome to the community, @RightPlayer.
Thank you for sharing full details of the problem.
Can you PM me the scene file? I won't need any background graphics, nor the Player if Brain2D also has this issue, but I will need to experience this issue on my end to work out what's going on.
I've sent you a PM, but for the benefit of others: I'll provide a fix in the next release, but removing the Rigidbody2D and CircleCollider2D components from the Player should remedy this in the meantime.
Yes, as stated in Chris' comment removing the RigidBody2D and CircleCollider2D will fix this problem.
To add to that, i was using InteractiveBoundary2D objects, which require a RigidBody2D and CircleCollider2d.
Chris suggested in the PM that to not loose that the functionality of InteractiveBoundary's you can keep the RigidBody2D and CircleCollider2D components and reduce the radius of the Circle to a really small one to reduce the effect of the bug.
@ChrisIceBox I am still having problems with this, even after removing the RigidBody2D and Circle.
At first it seemed that everything was working well untill i started clicking around a bit more. I noticed that sometimes Brain walks somewhere else of where i would think he would go.
To test this i did the following:
In the example i click really closely together and Brain seems to walk all the way up, which to me seems further away than to where he basically already was.
https://imgur.com/a/hGVTEMc
One thing I noted while testing this is that I don't see the little white squares in the blue pathfinding line, which according to the Manual meens my 'scale' is wrong. Seeing what i did above, how can my scale be wrong and might this cause this strange behavior?
In my own game scene my sprites (backgrounds) are about 3 times as big as the ParkSky from the 2D demo and in that scene Brain sometimes just walks the complete oppsite direction of where i clicked and pretty far out as well, that's when i started experimenting with this new scene and hoping to see the white squares the Manual is talking about.
Hmm the question about the scale / white squares is solved, i just had to zoom in a bit in the scene manager to be able to see them, so it seems my scale is correct (at least in the test scene).
Still curious about my other question regarding the pathfinding with 'Radially outwards from cursor' NavMesh search.
Here is what happens in my game's scene when click close together, somehow my Player decides to walk the complete opposite direction towards the center of the NavMesh or something.
https://imgur.com/a/GCgJgcm
The first gif - with Brain - demonstrates an issue with the current implementation of the "Radial outwards from cursor" option.
Fortunately, Unity introduced new methods in 2019 to make this operation much more accurate. I shall be including such an improvement to this as part of the upcoming v1.72.0 update.
As for the second, I'm not clear why your Player would start moving further inside the NavMesh - even with the above issue, they should at least move towards the edge.
You're welcome to test the upcoming release if you like - it may be that both issues are related. Send me a PM if you're intereseted.