I’ve been playing around with NodeLink2 to connect my characters to splines that connect recast graphs. Think of multiple graphs connected by multiple train systems that the player can be moved between. I was wondering if there was a way to get which node (1 or 2) that the player reached while moving on a recast graph which caused them to traverse off mesh. This lets the spline determine if they’re moving forward or backward on the spline. My current way consists of calculating the distance from the player to the nodeLink transform and the EndTransform, and based on which value is smaller, determine which node the player is likely at. Here is the code that I am using:
bool forward = true;
float magnitude1 = Vector3.Distance(link.nodeLink.transform.position, transform.position);
float magnitude2 = Vector3.Distance(link.nodeLink.EndTransform.position, transform.position);
if (magnitude1 < magnitude2)
{
forward = true;
}
else
{
forward = false;
}