A* Pathfinding Project

LayerGridGraph linecast over empy nodes problem


#1

Hello,
Using LayerGridGraph.Linecast, i’m trying to check if target is visible, and can be shoot. But i encountered a problem when trying to cast line over empty nodes, or from different graph layers. Line always hits the edge of layer (Images below say a thousand words :slight_smile: )


I debugged Linecast method, and calculation stop because “GetNeighbourAlongDirection” returns nothing at some point.

I found similar problem here (How to check if there is a straight path to target (layer grid graph)) but that did not help.

Any idea how to solve this? Where should i start? :smiley:
Any help will be appreciated, Thanks

PS: Using pro version


#2

Hi

It hits the edge because there is no valid path that goes in a straight line from the start to the end. Maybe you want Physics.Linecast instead? https://docs.unity3d.com/ScriptReference/Physics.Linecast.html


#3

Yea I suspect linecast needed a fully full valid path… I wanted to avoid using Physics.Linecast for other reasons, but looks like i have no choice :slight_smile:

Thanks for your time <3