Hi, I’ve updated from version 4.2.18 to 4.3.74, and it seems that the Linecast isn’t working the same way as before.
If I understand correctly from the documentation, it should check for any obstacles between two points.
Returns if there is an obstacle between origin and end on the graph.
This is not the same as Physics.Linecast, this function traverses the graph and looks for collisions instead of checking for collider intersection.
To ensure that none of my other scripts are affecting the linecast in a negative way, I have created a simple script and implemented it in a new scene.
Here is the script:
public class Test : MonoBehaviour
{
public Transform a;
public Transform b;
public Transform c;
void Update()
{
var nearest = AstarPath.active.data.navmesh.GetNearest(a.position, NNConstraint.None).node;
bool obstacle = AstarPath.active.data.navmesh.Linecast(a.position, b.position, nearest, out var hit);
c.position = hit.point;
Debug.Log("Obstacle: " + obstacle + " on: " + hit.point);
Debug.DrawLine(a.position, b.position, obstacle ? Color.red : Color.green);
}
}
When I execute this code, the linecast always returns true (obstacle) even if there is no obstacle between the two given points.
The only time it doesn’t return true is when the two points lie within the same triangle.
Here is a GIF showing the issue:
https://s12.gifyu.com/images/SuDle.gif
These are my A* settings:
Same test in 4.2.18
Could anyone help me with this issue?
Thanks in advance,
Julen.