bool HasLineOfSight(Vector3Int fromCoord, Vector3Int toCoord) { var from = HexUtil.ToWorld(fromCoord); var to = HexUtil.ToWorld(toCoord); var hasGround = true; var points = HexUtil.GetLineLoose(fromCoord, toCoord, CastRadius / 2, true); foreach (var item in points) { if (level[item] == 0) { hasGround = false; } } var dir = to - from; var r = new Ray(from + LineOfSightOffset, dir); var hit = Physics.SphereCast(r, CastRadius, dir.magnitude); Debug.DrawLine(from, to, (!hit && hasGround) ? Color.white : Color.red, 2); return(!hit && hasGround); }