Hello, i have noticed a bug and tested it several times to confirm it. It doesnt happen often but in some specific cases it occurs and i need it to work flawless for all the cases.
Anyways, in my project game i have agent traveling from city 1 to city 2 (point A to point B on the map). Map has areas where agent cant go and where it can go and recast graph takes care of that very well.
I want to display dashed lines where that agent is supposed to go, so in order to do that i am using GetRemainingPath as soon as path has been found and i fill list of Vector3s which i later pass to a method that draws dashed line from buffer[0] to buffer[1], then so on.
Agent itself always move on correct shortest path, however GetRemainingPath in some cases gives me slightly wrong list of Vector3s. I am completely confused why does that happen since it either should be error on both agent and dashed line since drawing dashed line should work with same data as Agent. What happens is that in some cases Dashed line has some points slightly off the path of Agent with extra points of turning where there shouldnt be any. I am uploading both cases where it works fine and when it doesnt for clarification.
Just to add, so in some cases after agent turns last time around area where it should go around because i set it up to avoid water, agent goes straight towards point B as it should, while dashed line shows sometimes 1 sometimes more than 1 point, which doesnt make line go straight from last necessary turn but small zigzag.
Just to add, error is not in drawing dashed line method, before i draw it i print out the points i got from GetRemainingPath, and n-1 point which is unecessary and wrong is there for some reason.
I believe this is partly from GetRemainingPath not taking into account the smoothing from FollowerEntity- don’t quote me on that, because I couldn’t find any concrete wording that really corroborates that. I may be mixing that up with something else I read before. This was the only thing I could find in the documentation and it’s not solid:
In contrast to other movement scripts, this movement script does not use path modifiers at all. Instead, this script contains its own internal FunnelModifier which it uses to simplify the path before it follows it.
So that’s what I believe is happening. I’ll have to tag @aron_granberg for a quick bit of clarification of if that’s correct though.
Thank you so much for the answer. Yes lets wait for Aron
If there is a way to apply that funnel and then get my list of Vector3s for drawing dashed line that would be amazing
I’m still not quite sure what the screenshots are showing, given they don’t show the agent’s destination and such.
But in general, the GetRemainingPath method returns the path that the agent is following. On top of this, the agent applies a steering behavior which, among other things, handles the turning radius and keeping a distance from walls. It’s not possible to account for this in GetRemainingPath, as it would essentially have to simulate the agent’s movement completely, frame by frame.
The agent also simplifies its path as it goes along, and it may be that it hasn’t simplified that part yet. You should be able to see if that’s the issue by enabling Follower Entity → Movement Debug Rendering = Path, and checking how the now visible orange path changes over time.
Thank you for answer Aron, i was looking forward for it.
Agent is going towards that castle (agent is that carriage if u can see it its not that big), while dashed white line is path i got instantly after path was found (search was completed)
Important update. I did manage to fix it so that dashed line is showing towards castle as it should. What i did is create Coroutine and wait few seconds before calling GetRemainingPath again and see if points were changed (which are directly responsible for drawing that dashed line). And voila now there is no that extra unecessary point slightly outside castle.
So as you said (which i didnt know honestly), agent simplified path after some time. Now i am checking how long it takes it to do so (get rid of that unecessary point)
It would be really helpfull if there would be a call i can make to simplify path instantly (call for that simplification) right after first one was found
Follower entity i am using. From A to B point algorithm finds one path while from B to A different one. They are similar in lenght but not the same, one is obviously shorter. I really need them to be the same path. Doesnt matter if not idealy shorest just need same path from A to B and from B to A. Any tips how ti fix this guys? <3