- A* version: [5.3.8]
- Unity version: [6000.2.10f1]
Hello, I’m having an issue where when I try to move my character using mousePosition, it can only find a path a few tiles ahead. It does show the destination in Scene through the blue indication line, as well as the destination inside of FollowerEntity under Debug info, but under the same thing it shows remaining distance to be infinity. I can partially bypass this by holding my mouse down, starting close and then dragging it but of course this isn’t the intended purpose.
I’m using Recast Graph and Follower Entity as my game is 2D.
My Voxel Size is set to 0.07 using Tiles at size 16, and Character Radius is 0.14.
I also have it functioning normally using a basic Vector3 instead of mouse, no matter the distance.
Here is the code of the mouse version, as well as the basic Vector3 one that works fine.
public void PointAndClick()
{
if (Input.GetMouseButton(1))
{
Vector3 worldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
worldPos.z = aiReference.position.z; //Keep z
var nearest = AstarPath.active.GetNearest(worldPos);
aiReference.destination = nearest.position;
}
}
public void GoToInteractable(InteractableObject interactable)
{
Vector3 intendedSpot = interactable.transform.position;(Vector3)interactable.interactionOffset;
GraphNode nearestNode = AstarPath.active.GetNearest(intendedSpot).node;
Vector3 snappedSpot = (Vector3)nearestNode.position;
aiReference.destination = snappedSpot;
}
Any help to what is going wrong would be greatly appreciated. I have tried to increase Max Frame Time to test if it was a performance issue and it did not help.