bool IsWalkable(NativeArray <Cell> buffer, float2 from, float2 to) { const float step = 0.25f; var vector = to - from; var length = math.length(vector); var unit = vector / length; var iterations = length / step; var currentCell = buffer[this.GetIndex(from.FloorToInt())]; for (var i = 0; i < iterations; i++) { var point = (i * step * unit) + from; var index = this.GetIndex(point.FloorToInt()); var cell = buffer[index]; if (cell.Blocked) { return(false); } if (cell.Height != currentCell.Height) { return(false); } } return(true); }