-
Notifications
You must be signed in to change notification settings - Fork 11
/
Part 3.html
445 lines (334 loc) · 88.1 KB
/
Part 3.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
<!DOCTYPE html>
<!-- saved from url=(0112)https://web.archive.org/web/20150214125646/http://alexstv.com:80/index.php/posts/unity-voxel-block-tutorial-pt-3 -->
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><script async="" src="./Part 3_files/analytics.js.descarga"></script><script src="./Part 3_files/analytics.js(1).descarga" type="text/javascript"></script>
<script type="text/javascript">window.addEventListener('DOMContentLoaded',function(){var v=archive_analytics.values;v.service='wb';v.server_name='wwwb-app39.us.archive.org';v.server_ms=302;archive_analytics.send_pageview({});});</script>
<script type="text/javascript" src="./Part 3_files/ait-client-rewrite.js.descarga" charset="utf-8"></script>
<script type="text/javascript">
WB_wombat_Init('https://web.archive.org/web', '20150214125646', 'alexstv.com:80');
</script>
<script type="text/javascript" src="./Part 3_files/wbhack.js.descarga" charset="utf-8"></script>
<script type="text/javascript">
__wbhack.init('https://web.archive.org/web');
</script>
<link rel="stylesheet" type="text/css" href="./Part 3_files/banner-styles.css">
<link rel="stylesheet" type="text/css" href="./Part 3_files/iconochive.css">
<!-- End Wayback Rewrite JS Include -->
<title>AlexStv</title>
<meta name="description" content="Code and things">
<link rel="stylesheet" href="./Part 3_files/reset.css">
<link rel="stylesheet" href="./Part 3_files/style.css">
<link rel="alternate" type="application/rss+xml" title="RSS" href="https://web.archive.org/web/20150214125646/http://alexstv.com:80/index.php/feeds/rss">
<link rel="shortcut icon" href="https://web.archive.org/web/20150214125646im_/http://alexstv.com:80/themes/AnchoredGallery/img/favicon.png">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script>var base = '/themes/AnchoredGallery/';</script>
<script src="./Part 3_files/zepto.js.descarga"></script>
<script src="./Part 3_files/main.js.descarga"></script>
<link href="./Part 3_files/css" rel="stylesheet" type="text/css">
<link href="./Part 3_files/css(1)" rel="stylesheet" type="text/css">
<link type="text/css" rel="Stylesheet" href="./Part 3_files/shCoreRDark.css">
<meta name="viewport" content="width=600">
<meta name="generator" content="Anchor CMS">
<meta property="og:title" content="AlexStv">
<meta property="og:type" content="website">
<meta property="og:url" content="posts/unity-voxel-block-tutorial-pt-3">
<meta property="og:image" content="/web/20150214125646im_/http://alexstv.com:80/themes/AnchoredGallery/img/og_image.gif">
<meta property="og:site_name" content="AlexStv">
<meta property="og:description" content="Code and things">
<!-- Include required JS files -->
<script type="text/javascript" src="./Part 3_files/shCore.js.descarga"></script>
<script type="text/javascript" src="./Part 3_files/shBrushCSharp.js.descarga"></script>
<script type="text/javascript" src="./Part 3_files/jquery.min.js.descarga"></script>
<!-- Include jQuery Syntax Highlighter -->
<script type="text/javascript" src="./Part 3_files/jquery.syntaxhighlighter.min.js.descarga"></script>
<!-- Initialise jQuery Syntax Highlighter -->
<script type="text/javascript">$.SyntaxHighlighter.init();</script>
<!-- Initialise jQuery Syntax Highlighter -->
<script type="text/javascript">
$.SyntaxHighlighter.init({
'alternateLines':true
});
</script>
<script type="text/javascript">
SyntaxHighlighter.all()
</script></head>
<body class="posts home js-enabled"><div id="wm-ipp" lang="en" style="display: block; direction: ltr;">
<div style="position:fixed;left:0;top:0;right:0;">
<div id="wm-ipp-inside">
<div style="position:relative;">
<div id="wm-logo" style="float:left;width:130px;padding-top:10px;">
<a href="https://web.archive.org/web/" title="Wayback Machine home page"><img src="./Part 3_files/wayback-toolbar-logo.png" alt="Wayback Machine" width="110" height="39" border="0"></a>
</div>
<div class="r" style="float:right;">
<div id="wm-btns" style="text-align:right;height:25px;">
<div id="wm-save-snapshot-success">success</div>
<div id="wm-save-snapshot-fail">fail</div>
<a href="https://web.archive.org/web/20150214125646/http://alexstv.com:80/index.php/posts/unity-voxel-block-tutorial-pt-3#" onclick="__wm.saveSnapshot('http://alexstv.com:80/index.php/posts/unity-voxel-block-tutorial-pt-3', '20150214125646')" title="Share via My Web Archive" id="wm-save-snapshot-open" style="display: none;">
<span class="iconochive-web"></span>
</a>
<a href="https://archive.org/account/login.php" title="Sign In" id="wm-sign-in" style="display: inline-block;">
<span class="iconochive-person"></span>
</a>
<span id="wm-save-snapshot-in-progress" class="iconochive-web" style="display: none;"></span>
<a href="http://faq.web.archive.org/" title="Get some help using the Wayback Machine" style="top:-6px;"><span class="iconochive-question" style="color:rgb(87,186,244);font-size:160%;"></span></a>
<a id="wm-tb-close" href="https://web.archive.org/web/20150214125646/http://alexstv.com:80/index.php/posts/unity-voxel-block-tutorial-pt-3#close" onclick="__wm.h(event);return false;" style="top:-2px;" title="Close the toolbar"><span class="iconochive-remove-circle" style="color:#888888;font-size:240%;"></span></a>
</div>
<div id="wm-share" style="text-align:right;">
<a href="https://web.archive.org/web/20150214125646/http://alexstv.com:80/index.php/posts/unity-voxel-block-tutorial-pt-3#" onclick="window.open('https://www.facebook.com/sharer/sharer.php?u=https://web.archive.org/web/20150214125646/http://alexstv.com:80/index.php/posts/unity-voxel-block-tutorial-pt-3', '', 'height=400,width=600'); return false;" title="Share on Facebook" style="margin-right:5px;" target="_blank"><span class="iconochive-facebook" style="color:#3b5998;font-size:160%;"></span></a>
<a href="https://web.archive.org/web/20150214125646/http://alexstv.com:80/index.php/posts/unity-voxel-block-tutorial-pt-3#" onclick="window.open('https://twitter.com/intent/tweet?text=https://web.archive.org/web/20150214125646/http://alexstv.com:80/index.php/posts/unity-voxel-block-tutorial-pt-3&via=internetarchive', '', 'height=400,width=600'); return false;" title="Share on Twitter" style="margin-right:5px;" target="_blank"><span class="iconochive-twitter" style="color:#1dcaff;font-size:160%;"></span></a>
</div>
</div>
<table class="c" style="">
<tbody>
<tr>
<td class="u" colspan="2">
<form target="_top" method="get" action="https://web.archive.org/web/submit" name="wmtb" id="wmtb"><input type="text" name="url" id="wmtbURL" value="http://alexstv.com:80/index.php/posts/unity-voxel-block-tutorial-pt-3" onfocus="this.focus();this.select();" autocomplete="off"><input type="hidden" name="type" value="replay"><input type="hidden" name="date" value="20150214125646"><input type="submit" value="Go"></form>
</td>
<td class="n" rowspan="2" style="width:110px;">
<table>
<tbody>
<!-- NEXT/PREV MONTH NAV AND MONTH INDICATOR -->
<tr class="m">
<td class="b" nowrap="nowrap">Jan</td>
<td class="c" id="displayMonthEl" title="You are here: 12:56:46 Feb 14, 2015">FEB</td>
<td class="f" nowrap="nowrap"><a href="https://web.archive.org/web/20150318013051/http://alexstv.com:80/index.php/posts/unity-voxel-block-tutorial-pt-3" title="18 Mar 2015"><strong>Mar</strong></a></td>
</tr>
<!-- NEXT/PREV CAPTURE NAV AND DAY OF MONTH INDICATOR -->
<tr class="d">
<td class="b" nowrap="nowrap"><a href="https://web.archive.org/web/20150131080814/http://alexstv.com:80/index.php/posts/unity-voxel-block-tutorial-pt-3" title="08:08:14 Jan 31, 2015"><img src="./Part 3_files/wm_tb_prv_on.png" alt="Previous capture" width="14" height="16" border="0"></a></td>
<td class="c" id="displayDayEl" style="width:34px;font-size:24px;white-space:nowrap;" title="You are here: 12:56:46 Feb 14, 2015">14</td>
<td class="f" nowrap="nowrap"><a href="https://web.archive.org/web/20150318013051/http://alexstv.com:80/index.php/posts/unity-voxel-block-tutorial-pt-3" title="01:30:51 Mar 18, 2015"><img src="./Part 3_files/wm_tb_nxt_on.png" alt="Next capture" width="14" height="16" border="0"></a></td>
</tr>
<!-- NEXT/PREV YEAR NAV AND YEAR INDICATOR -->
<tr class="y">
<td class="b" nowrap="nowrap">2014</td>
<td class="c" id="displayYearEl" title="You are here: 12:56:46 Feb 14, 2015">2015</td>
<td class="f" nowrap="nowrap"><a href="https://web.archive.org/web/20160529131433/http://alexstv.com:80/index.php/posts/unity-voxel-block-tutorial-pt-3" title="29 May 2016"><strong>2016</strong></a></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="s">
<div id="wm-nav-captures"><a class="t" href="https://web.archive.org/web/*/http://alexstv.com:80/index.php/posts/unity-voxel-block-tutorial-pt-3" title="See a list of every capture for this URL">30 captures</a><div class="r" title="Timespan for captures of this URL">31 Jan 2015 - 16 Oct 2017</div></div>
</td>
<td class="k">
<a href="https://web.archive.org/web/20150214125646/http://alexstv.com:80/index.php/posts/unity-voxel-block-tutorial-pt-3" id="wm-graph-anchor">
<div id="wm-ipp-sparkline" title="Explore captures for this URL" style="position: relative">
<canvas id="wm-sparkline-canvas" width="575" height="27" border="0"></canvas>
<div class="yt" style="display: none; width: 25px; height: 27px;"></div><div class="mt" style="display: none; width: 2px; height: 27px;"></div></div>
</a>
</td>
</tr>
</tbody>
</table>
<div style="position:absolute;bottom:0;right:2px;text-align:right;">
<a id="wm-expand" class="wm-btn wm-closed" href="https://web.archive.org/web/20150214125646/http://alexstv.com:80/index.php/posts/unity-voxel-block-tutorial-pt-3#expand" onclick="__wm.ex(event);return false;"><span id="wm-expand-icon" class="iconochive-down-solid"></span> <span style="font-size:80%">About this capture</span></a>
</div>
</div>
<div id="wm-capinfo" style="border-top:1px solid #777;display:none; overflow: hidden">
<div style="background-color:#666;color:#fff;font-weight:bold;text-align:center">COLLECTED BY</div>
<div style="padding:3px;position:relative" id="wm-collected-by-content">
<div style="display:inline-block;vertical-align:top;width:50%;">
<span class="c-logo" style="background-image:url(https://archive.org/services/img/alexacrawls);"></span>
Organization: <a style="color:#33f;" href="https://archive.org/details/alexacrawls" target="_new"><span class="wm-title">Alexa Crawls</span></a>
<div style="max-height:75px;overflow:hidden;position:relative;">
<div style="position:absolute;top:0;left:0;width:100%;height:75px;background:linear-gradient(to bottom,rgba(255,255,255,0) 0%,rgba(255,255,255,0) 90%,rgba(255,255,255,255) 100%);"></div>
Starting in 1996, <a href="http://www.alexa.com/">Alexa Internet</a> has been donating their crawl data to the Internet Archive. Flowing in every day, these data are added to the <a href="http://web.archive.org/">Wayback Machine</a> after an embargo period.
</div>
</div>
<div style="display:inline-block;vertical-align:top;width:49%;">
<span class="c-logo" style="background-image:url(https://archive.org/services/img/alexacrawls)"></span>
<div>Collection: <a style="color:#33f;" href="https://archive.org/details/alexacrawls" target="_new"><span class="wm-title">Alexa Crawls</span></a></div>
<div style="max-height:75px;overflow:hidden;position:relative;">
<div style="position:absolute;top:0;left:0;width:100%;height:75px;background:linear-gradient(to bottom,rgba(255,255,255,0) 0%,rgba(255,255,255,0) 90%,rgba(255,255,255,255) 100%);"></div>
Starting in 1996, <a href="http://www.alexa.com/">Alexa Internet</a> has been donating their crawl data to the Internet Archive. Flowing in every day, these data are added to the <a href="http://web.archive.org/">Wayback Machine</a> after an embargo period.
</div>
</div>
</div>
<div style="background-color:#666;color:#fff;font-weight:bold;text-align:center" title="Timestamps for the elements of this page">TIMESTAMPS</div>
<div>
<div id="wm-capresources" style="margin:0 5px 5px 5px;max-height:250px;overflow-y:scroll !important"></div>
<div id="wm-capresources-loading" style="text-align:left;margin:0 20px 5px 5px;display:none"><img src="./Part 3_files/loading.gif" alt="loading"></div>
</div>
</div></div></div></div><!-- BEGIN WAYBACK TOOLBAR INSERT -->
<script type="text/javascript" src="./Part 3_files/timestamp.js.descarga" charset="utf-8"></script>
<script type="text/javascript" src="./Part 3_files/graph-calc.js.descarga" charset="utf-8"></script>
<script type="text/javascript" src="./Part 3_files/auto-complete.js.descarga" charset="utf-8"></script>
<script type="text/javascript" src="./Part 3_files/toolbar.js.descarga" charset="utf-8"></script>
<style type="text/css">
body {
margin-top:0 !important;
padding-top:0 !important;
/*min-width:800px !important;*/
}
.wb-autocomplete-suggestions {
text-align: left; cursor: default; border: 1px solid #ccc; border-top: 0; background: #fff; box-shadow: -1px 1px 3px rgba(0,0,0,.1);
position: absolute; display: none; z-index: 2147483647; max-height: 254px; overflow: hidden; overflow-y: auto; box-sizing: border-box;
}
.wb-autocomplete-suggestion { position: relative; padding: 0 .6em; line-height: 23px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1.02em; color: #333; }
.wb-autocomplete-suggestion b { font-weight: bold; }
.wb-autocomplete-suggestion.selected { background: #f0f0f0; }
</style>
<script type="text/javascript">
__wm.bt(575,27,25,2,"web","http://alexstv.com:80/index.php/posts/unity-voxel-block-tutorial-pt-3","2015-02-14",1996);
</script><div class="wb-autocomplete-suggestions " style="left: 147px; top: 5423px; width: 643px;"></div>
<!-- END WAYBACK TOOLBAR INSERT -->
<div style="background-color:#4774A5; overflow:hidden; background-position:center; background-image:url('https://web.archive.org/web/20150214125646im_/http://4.bp.blogspot.com/-9w7pH08mSaM/UGbaDEz3kOI/AAAAAAAADeI/9XWFFsdLdwg/s1600/body.png');background-repeat:repeat;">
<article class="wrapper">
<a href="https://web.archive.org/web/20150214125646/http://alexstv.com:80/index.php/">
<header>
<titletext>AlexStv</titletext>
</header>
</a>
<div class="pagewrapper" style="width:100%">
<a href="https://web.archive.org/web/20150214125646/http://alexstv.com:80/index.php/category/general" title="General">
<div class="page" style="width:33.333333333333%">
<stamptext>General (2)</stamptext>
</div>
</a>
<a href="https://web.archive.org/web/20150214125646/http://alexstv.com:80/index.php/category/voxels" title="Voxels">
<div class="page" style="width:33.333333333333%">
<stamptext>Voxels (7)</stamptext>
</div>
</a>
<a href="https://web.archive.org/web/20150214125646/http://alexstv.com:80/index.php/category/grapple" title="Grapple">
<div class="page" style="width:33.333333333333%">
<stamptext>Grapple (3)</stamptext>
</div>
</a>
</div>
</article>
</div>
<div class="bg2">
<article class="wrapper">
<div class="post">
<div id="filler">
<div class="description" style="width:100%; padding-bottom:30px; background-color:#3C5C89;">
<h1 style="color:#fff;">Unity voxel block tutorial pt. 3</h1>
</div>
</div>
<div id="filler">
<div class="description">
<bodytext>
<p>Once again welcome to the voxel block tutorial, this time we're going to expand to multiple chunks and the system to handle infinite terrain.</p>
<p>We'll start this part by adding a new script called world for handling the larger scale of our voxel terrain that's going to be the focus of this part but before we can create that script we'll need to set up a bit first. the world script will need a collection variable for the chunks it manages that allows for easy access based on their 3d positions and lets us add and remove chunks arbitrarily. In the last tutorial I used a 3 dimensional array because we could store chunks where their index represented their position in 3 dimensions but an array wasn't the best idea for infinite terrain and a lot of people were interested in that so this time we'll use a dictionary collection.</p>
<p></p><div class="infobox"><infoboxtext><p>A dictionary stores values along with a key that can be any type, then you can look up a value by its key making it fast to find a value without knowing its index as long as you know its key</p></infoboxtext></div><p></p>
<p>To use a dictionary we're going to create a struct to use as a key, this struct will be the chunk's position in the world so so before we can start working on the world script <strong>create a script called WorldPos</strong>:</p>
<p> </p></bodytext></div> </div> <div class="codeblock"><div><div id="highlighter_430896" class="syntaxhighlighter csharp"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><div class="line number7 index6 alt2">7</div><div class="line number8 index7 alt1">8</div><div class="line number9 index8 alt2">9</div><div class="line number10 index9 alt1">10</div><div class="line number11 index10 alt2">11</div><div class="line number12 index11 alt1">12</div><div class="line number13 index12 alt2">13</div><div class="line number14 index13 alt1">14</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">using</code> <code class="csharp plain">UnityEngine;</code></div><div class="line number2 index1 alt1"><code class="csharp spaces"> </code><code class="csharp keyword">using</code> <code class="csharp plain">System.Collections;</code></div><div class="line number3 index2 alt2"> </div><div class="line number4 index3 alt1"><code class="csharp spaces"> </code><code class="csharp keyword">public</code> <code class="csharp keyword">struct</code> <code class="csharp plain">WorldPos</code></div><div class="line number5 index4 alt2"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number6 index5 alt1"><code class="csharp spaces"> </code><code class="csharp keyword">public</code> <code class="csharp keyword">int</code> <code class="csharp plain">x, y, z;</code></div><div class="line number7 index6 alt2"> </div><div class="line number8 index7 alt1"><code class="csharp spaces"> </code><code class="csharp keyword">public</code> <code class="csharp plain">WorldPos(</code><code class="csharp keyword">int</code> <code class="csharp plain">x, </code><code class="csharp keyword">int</code> <code class="csharp plain">y, </code><code class="csharp keyword">int</code> <code class="csharp plain">z)</code></div><div class="line number9 index8 alt2"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number10 index9 alt1"><code class="csharp spaces"> </code><code class="csharp keyword">this</code><code class="csharp plain">.x = x;</code></div><div class="line number11 index10 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">this</code><code class="csharp plain">.y = y;</code></div><div class="line number12 index11 alt1"><code class="csharp spaces"> </code><code class="csharp keyword">this</code><code class="csharp plain">.z = z;</code></div><div class="line number13 index12 alt2"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div><div class="line number14 index13 alt1"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div></div></td></tr></tbody></table></div></div></div><div id="filler"> <div class="description" style="padding-top:0px"> <bodytext><p></p>
<p>World position is what we'll use for any voxel positions that need to be stored as a single value and it can be used as a key in our dictionary. In it you can see we have three ints, x, y and z and a constructor that assigns all three. Now we will also override the default Equals function with our own because it's a little faster than the default value type Equals.</p>
<p> </p></bodytext></div> </div> <div class="codeblock"><div><div id="highlighter_896651" class="syntaxhighlighter csharp"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><div class="line number7 index6 alt2">7</div><div class="line number8 index7 alt1">8</div><div class="line number9 index8 alt2">9</div><div class="line number10 index9 alt1">10</div><div class="line number11 index10 alt2">11</div><div class="line number12 index11 alt1">12</div><div class="line number13 index12 alt2">13</div><div class="line number14 index13 alt1">14</div><div class="line number15 index14 alt2">15</div><div class="line number16 index15 alt1">16</div><div class="line number17 index16 alt2">17</div><div class="line number18 index17 alt1">18</div><div class="line number19 index18 alt2">19</div><div class="line number20 index19 alt1">20</div><div class="line number21 index20 alt2">21</div><div class="line number22 index21 alt1">22</div><div class="line number23 index22 alt2">23</div><div class="line number24 index23 alt1">24</div><div class="line number25 index24 alt2">25</div><div class="line number26 index25 alt1">26</div><div class="line number27 index26 alt2">27</div><div class="line number28 index27 alt1">28</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">public</code> <code class="csharp keyword">struct</code> <code class="csharp plain">WorldPos</code></div><div class="line number2 index1 alt1"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number3 index2 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">public</code> <code class="csharp keyword">int</code> <code class="csharp plain">x, y, z;</code></div><div class="line number4 index3 alt1"> </div><div class="line number5 index4 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">public</code> <code class="csharp plain">WorldPos(</code><code class="csharp keyword">int</code> <code class="csharp plain">x, </code><code class="csharp keyword">int</code> <code class="csharp plain">y, </code><code class="csharp keyword">int</code> <code class="csharp plain">z)</code></div><div class="line number6 index5 alt1"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number7 index6 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">this</code><code class="csharp plain">.x = x;</code></div><div class="line number8 index7 alt1"><code class="csharp spaces"> </code><code class="csharp keyword">this</code><code class="csharp plain">.y = y;</code></div><div class="line number9 index8 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">this</code><code class="csharp plain">.z = z;</code></div><div class="line number10 index9 alt1"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div><div class="line number11 index10 alt2"> </div><div class="line number12 index11 alt1"><code class="csharp spaces"> </code><code class="csharp comments">//Add this function:</code></div><div class="line number13 index12 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">public</code> <code class="csharp keyword">override</code> <code class="csharp keyword">bool</code> <code class="csharp plain">Equals(</code><code class="csharp keyword">object</code> <code class="csharp plain">obj)</code></div><div class="line number14 index13 alt1"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number15 index14 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">if</code> <code class="csharp plain">(!(obj </code><code class="csharp keyword">is</code> <code class="csharp plain">WorldPos))</code></div><div class="line number16 index15 alt1"><code class="csharp spaces"> </code><code class="csharp keyword">return</code> <code class="csharp keyword">false</code><code class="csharp plain">;</code></div><div class="line number17 index16 alt2"> </div><div class="line number18 index17 alt1"><code class="csharp spaces"> </code><code class="csharp plain">WorldPos pos = (WorldPos)obj;</code></div><div class="line number19 index18 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">if</code> <code class="csharp plain">(pos.x != x || pos.y != y || pos.z != z)</code></div><div class="line number20 index19 alt1"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number21 index20 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">return</code> <code class="csharp keyword">false</code><code class="csharp plain">;</code></div><div class="line number22 index21 alt1"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div><div class="line number23 index22 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">else</code></div><div class="line number24 index23 alt1"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number25 index24 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">return</code> <code class="csharp keyword">true</code><code class="csharp plain">;</code></div><div class="line number26 index25 alt1"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div><div class="line number27 index26 alt2"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div><div class="line number28 index27 alt1"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div></div></td></tr></tbody></table></div></div></div><div id="filler"> <div class="description" style="padding-top:0px"> <bodytext><p></p>
<p>What this does is check if the object being compared is a WorldPos and that x, y and z are equal to this one's x, y and z. This gives us a variable for positions that can quickly be compared.</p>
<p>Now <strong>create the World script</strong> and use the automatically generated content but add this line at the top of the file with the other includes:
</p></bodytext></div> </div> <div class="codeblock"><div><div id="highlighter_134073" class="syntaxhighlighter csharp"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="csharp keyword">using</code> <code class="csharp plain">System.Collections.Generic;</code></div></div></td></tr></tbody></table></div></div></div><div id="filler"> <div class="description" style="padding-top:0px"> <bodytext><p></p>
<p>This let's us use the dictionary. Next let's add the dictionary variable:
</p></bodytext></div> </div> <div class="codeblock"><div><div id="highlighter_623404" class="syntaxhighlighter csharp"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">public</code> <code class="csharp plain">Dictionary<WorldPos, Chunk> chunks = </code><code class="csharp keyword">new</code> <code class="csharp plain">Dictionary<WorldPos, Chunk>();</code></div></div></td></tr></tbody></table></div></div></div><div id="filler"> <div class="description" style="padding-top:0px"> <bodytext><p></p>
<p>It defines a dictionary with WorldPos as the key and Chunk as the value. We can use this to store as many chunks as we want in any position and out methods will look them up based on their positions.</p>
<p>Let's start with a function to create new chunks, since chunks are game objects we'll need to use the instantiate method with a prefab to create the chunks so create a variable chunkPrefab:
</p></bodytext></div> </div> <div class="codeblock"><div><div id="highlighter_279802" class="syntaxhighlighter csharp"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">public</code> <code class="csharp plain">GameObject chunkPrefab;</code></div></div></td></tr></tbody></table></div></div></div><div id="filler"> <div class="description" style="padding-top:0px"> <bodytext><p></p>
<p>And also create a prefab of a chunk. Use the chunk object we've been using or create a new one. It just needs to be a game object with the material applied and chunk script which automatically includes the mesh renderer, mesh filter and mesh collide . By the way make sure your mesh collider has convex set to false or your colliders wont work. Make a prefab of it by dragging it from the hierarchy to the project view. Then delete it from the scene and make a new object with the world script on it and set the chunkPrefab variable to the one we just made.</p>
<p>We'll create a function to add chunks to the game but first we need change the chunk script a little so that they're initialized from world not on their own. So in the chunk script's Start function remove everything except the lines that fetch the mesh filter and mesh collider so it looks like this:</p>
<p> </p></bodytext></div> </div> <div class="codeblock"><div><div id="highlighter_240453" class="syntaxhighlighter csharp"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="csharp comments">//Chunk.cs</code></div><div class="line number2 index1 alt1"><code class="csharp spaces"> </code><code class="csharp keyword">void</code> <code class="csharp plain">Start () {</code></div><div class="line number3 index2 alt2"><code class="csharp spaces"> </code><code class="csharp plain">filter = gameObject.GetComponent<MeshFilter>();</code></div><div class="line number4 index3 alt1"><code class="csharp spaces"> </code><code class="csharp plain">coll = gameObject.GetComponent<MeshCollider>();</code></div><div class="line number5 index4 alt2"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div></div></td></tr></tbody></table></div></div></div><div id="filler"> <div class="description" style="padding-top:0px"> <bodytext><p></p>
<p>And also change the blocks variable to set its size when it's defined:
</p></bodytext></div> </div> <div class="codeblock"><div><div id="highlighter_827392" class="syntaxhighlighter csharp"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="csharp comments">//chunk.cs</code></div><div class="line number2 index1 alt1"><code class="csharp spaces"> </code><code class="csharp keyword">private</code> <code class="csharp plain">Block[ , , ] blocks = </code><code class="csharp keyword">new</code> <code class="csharp plain">Block[chunkSize, chunkSize, chunkSize];</code></div></div></td></tr></tbody></table></div></div></div><div id="filler"> <div class="description" style="padding-top:0px"> <bodytext><p></p>
<p>And while we're here add a World variable so chunks always have a reference to the world containing them and a WorldPos variable so the chunk has easy access to it's position in the world without using floats through Transform.position:</p>
<p> </p></bodytext></div> </div> <div class="codeblock"><div><div id="highlighter_432333" class="syntaxhighlighter csharp"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">public</code> <code class="csharp plain">World world;</code></div><div class="line number2 index1 alt1"><code class="csharp spaces"> </code><code class="csharp keyword">public</code> <code class="csharp plain">WorldPos pos;</code></div></div></td></tr></tbody></table></div></div></div><div id="filler"> <div class="description" style="padding-top:0px"> <bodytext><p></p>
<p>Now <strong>in the World.cs script</strong> we can start creating chunks with a new function in the world script, open the world file to add a new function:
</p></bodytext></div> </div> <div class="codeblock"><div><div id="highlighter_746258" class="syntaxhighlighter csharp"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><div class="line number7 index6 alt2">7</div><div class="line number8 index7 alt1">8</div><div class="line number9 index8 alt2">9</div><div class="line number10 index9 alt1">10</div><div class="line number11 index10 alt2">11</div><div class="line number12 index11 alt1">12</div><div class="line number13 index12 alt2">13</div><div class="line number14 index13 alt1">14</div><div class="line number15 index14 alt2">15</div><div class="line number16 index15 alt1">16</div><div class="line number17 index16 alt2">17</div><div class="line number18 index17 alt1">18</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">public</code> <code class="csharp keyword">void</code> <code class="csharp plain">CreateChunk(</code><code class="csharp keyword">int</code> <code class="csharp plain">x, </code><code class="csharp keyword">int</code> <code class="csharp plain">y, </code><code class="csharp keyword">int</code> <code class="csharp plain">z)</code></div><div class="line number2 index1 alt1"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number3 index2 alt2"><code class="csharp spaces"> </code><code class="csharp plain">WorldPos worldPos = </code><code class="csharp keyword">new</code> <code class="csharp plain">WorldPos(x, y , z);</code></div><div class="line number4 index3 alt1"><code class="csharp spaces"> </code> </div><div class="line number5 index4 alt2"><code class="csharp spaces"> </code><code class="csharp comments">//Instantiate the chunk at the coordinates using the chunk prefab</code></div><div class="line number6 index5 alt1"><code class="csharp spaces"> </code><code class="csharp plain">GameObject newChunkObject = Instantiate(</code></div><div class="line number7 index6 alt2"><code class="csharp spaces"> </code><code class="csharp plain">chunkPrefab, </code><code class="csharp keyword">new</code> <code class="csharp plain">Vector3(x, y, z),</code></div><div class="line number8 index7 alt1"><code class="csharp spaces"> </code><code class="csharp plain">Quaternion.Euler(Vector3.zero)</code></div><div class="line number9 index8 alt2"><code class="csharp spaces"> </code><code class="csharp plain">) </code><code class="csharp keyword">as</code> <code class="csharp plain">GameObject;</code></div><div class="line number10 index9 alt1"><code class="csharp spaces"> </code> </div><div class="line number11 index10 alt2"><code class="csharp spaces"> </code><code class="csharp plain">Chunk newChunk = newChunkObject.GetComponent<Chunk>();</code></div><div class="line number12 index11 alt1"><code class="csharp spaces"> </code> </div><div class="line number13 index12 alt2"><code class="csharp spaces"> </code><code class="csharp plain">newChunk.pos = worldPos;</code></div><div class="line number14 index13 alt1"><code class="csharp spaces"> </code><code class="csharp plain">newChunk.world = </code><code class="csharp keyword">this</code><code class="csharp plain">;</code></div><div class="line number15 index14 alt2"><code class="csharp spaces"> </code> </div><div class="line number16 index15 alt1"><code class="csharp spaces"> </code><code class="csharp comments">//Add it to the chunks dictionary with the position as the key</code></div><div class="line number17 index16 alt2"><code class="csharp spaces"> </code><code class="csharp plain">chunks.Add(worldPos, newChunk);</code></div><div class="line number18 index17 alt1"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div></div></td></tr></tbody></table></div></div></div><div id="filler"> <div class="description" style="padding-top:0px"> <bodytext><p></p>
<p>Here we instantiate the prefab in the world at the coordinates supplied then set the chunk's pos and world variables and lastly add it to the dictionary.</p>
<p>Let's put something together that lets us test this. In the world start function add the following to create some chunks on startup:</p>
<p> </p></bodytext></div> </div> <div class="codeblock"><div><div id="highlighter_896889" class="syntaxhighlighter csharp"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><div class="line number7 index6 alt2">7</div><div class="line number8 index7 alt1">8</div><div class="line number9 index8 alt2">9</div><div class="line number10 index9 alt1">10</div><div class="line number11 index10 alt2">11</div><div class="line number12 index11 alt1">12</div><div class="line number13 index12 alt2">13</div><div class="line number14 index13 alt1">14</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">void</code> <code class="csharp plain">Start()</code></div><div class="line number2 index1 alt1"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number3 index2 alt2"> </div><div class="line number4 index3 alt1"><code class="csharp spaces"> </code><code class="csharp keyword">for</code> <code class="csharp plain">(</code><code class="csharp keyword">int</code> <code class="csharp plain">x = -2; x < 2; x++)</code></div><div class="line number5 index4 alt2"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number6 index5 alt1"><code class="csharp spaces"> </code><code class="csharp keyword">for</code> <code class="csharp plain">(</code><code class="csharp keyword">int</code> <code class="csharp plain">y = -1; y < 1; y++)</code></div><div class="line number7 index6 alt2"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number8 index7 alt1"><code class="csharp spaces"> </code><code class="csharp keyword">for</code> <code class="csharp plain">(</code><code class="csharp keyword">int</code> <code class="csharp plain">z = -1; z < 1; z++)</code></div><div class="line number9 index8 alt2"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number10 index9 alt1"><code class="csharp spaces"> </code><code class="csharp plain">CreateChunk(x * 16, y* 16, z * 16);</code></div><div class="line number11 index10 alt2"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div><div class="line number12 index11 alt1"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div><div class="line number13 index12 alt2"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div><div class="line number14 index13 alt1"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div></div></td></tr></tbody></table></div></div></div><div id="filler"> <div class="description" style="padding-top:0px"> <bodytext><p></p>
<p>Now we need functions in the world script that can get and set specific blocks in the world. We want the world script to be able to call get block with a global coordinate and then get the correct chunk and get the block from it. We'll need to first find the chunk containing this block, then call that chunk's get block script to return the block:</p>
<p> </p></bodytext></div> </div> <div class="codeblock"><div><div id="highlighter_373952" class="syntaxhighlighter csharp"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><div class="line number7 index6 alt2">7</div><div class="line number8 index7 alt1">8</div><div class="line number9 index8 alt2">9</div><div class="line number10 index9 alt1">10</div><div class="line number11 index10 alt2">11</div><div class="line number12 index11 alt1">12</div><div class="line number13 index12 alt2">13</div><div class="line number14 index13 alt1">14</div><div class="line number15 index14 alt2">15</div><div class="line number16 index15 alt1">16</div><div class="line number17 index16 alt2">17</div><div class="line number18 index17 alt1">18</div><div class="line number19 index18 alt2">19</div><div class="line number20 index19 alt1">20</div><div class="line number21 index20 alt2">21</div><div class="line number22 index21 alt1">22</div><div class="line number23 index22 alt2">23</div><div class="line number24 index23 alt1">24</div><div class="line number25 index24 alt2">25</div><div class="line number26 index25 alt1">26</div><div class="line number27 index26 alt2">27</div><div class="line number28 index27 alt1">28</div><div class="line number29 index28 alt2">29</div><div class="line number30 index29 alt1">30</div><div class="line number31 index30 alt2">31</div><div class="line number32 index31 alt1">32</div><div class="line number33 index32 alt2">33</div><div class="line number34 index33 alt1">34</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">public</code> <code class="csharp plain">Chunk GetChunk(</code><code class="csharp keyword">int</code> <code class="csharp plain">x, </code><code class="csharp keyword">int</code> <code class="csharp plain">y, </code><code class="csharp keyword">int</code> <code class="csharp plain">z)</code></div><div class="line number2 index1 alt1"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number3 index2 alt2"><code class="csharp spaces"> </code><code class="csharp plain">WorldPos pos = </code><code class="csharp keyword">new</code> <code class="csharp plain">WorldPos();</code></div><div class="line number4 index3 alt1"><code class="csharp spaces"> </code><code class="csharp keyword">float</code> <code class="csharp plain">multiple = Chunk.chunkSize;</code></div><div class="line number5 index4 alt2"><code class="csharp spaces"> </code><code class="csharp plain">pos.x = Mathf.FloorToInt(x / multiple ) * Chunk.chunkSize;</code></div><div class="line number6 index5 alt1"><code class="csharp spaces"> </code><code class="csharp plain">pos.y = Mathf.FloorToInt(y / multiple ) * Chunk.chunkSize;</code></div><div class="line number7 index6 alt2"><code class="csharp spaces"> </code><code class="csharp plain">pos.z = Mathf.FloorToInt(z / multiple ) * Chunk.chunkSize;</code></div><div class="line number8 index7 alt1"> </div><div class="line number9 index8 alt2"><code class="csharp spaces"> </code><code class="csharp plain">Chunk containerChunk = </code><code class="csharp keyword">null</code><code class="csharp plain">;</code></div><div class="line number10 index9 alt1"> </div><div class="line number11 index10 alt2"><code class="csharp spaces"> </code><code class="csharp plain">chunks.TryGetValue(pos, </code><code class="csharp keyword">out</code> <code class="csharp plain">containerChunk);</code></div><div class="line number12 index11 alt1"><code class="csharp spaces"> </code> </div><div class="line number13 index12 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">return</code> <code class="csharp plain">containerChunk;</code></div><div class="line number14 index13 alt1"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div><div class="line number15 index14 alt2"> </div><div class="line number16 index15 alt1"><code class="csharp spaces"> </code><code class="csharp keyword">public</code> <code class="csharp plain">Block GetBlock(</code><code class="csharp keyword">int</code> <code class="csharp plain">x, </code><code class="csharp keyword">int</code> <code class="csharp plain">y, </code><code class="csharp keyword">int</code> <code class="csharp plain">z)</code></div><div class="line number17 index16 alt2"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number18 index17 alt1"><code class="csharp spaces"> </code><code class="csharp plain">Chunk containerChunk = GetChunk(x, y, z);</code></div><div class="line number19 index18 alt2"> </div><div class="line number20 index19 alt1"><code class="csharp spaces"> </code><code class="csharp keyword">if</code> <code class="csharp plain">(containerChunk != </code><code class="csharp keyword">null</code><code class="csharp plain">)</code></div><div class="line number21 index20 alt2"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number22 index21 alt1"><code class="csharp spaces"> </code><code class="csharp plain">Block block = containerChunk.GetBlock(</code></div><div class="line number23 index22 alt2"><code class="csharp spaces"> </code><code class="csharp plain">x - containerChunk.pos.x,</code></div><div class="line number24 index23 alt1"><code class="csharp spaces"> </code><code class="csharp plain">y -containerChunk.pos.y, </code></div><div class="line number25 index24 alt2"><code class="csharp spaces"> </code><code class="csharp plain">z - containerChunk.pos.z);</code></div><div class="line number26 index25 alt1"><code class="csharp spaces"> </code> </div><div class="line number27 index26 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">return</code> <code class="csharp plain">block;</code></div><div class="line number28 index27 alt1"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div><div class="line number29 index28 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">else</code></div><div class="line number30 index29 alt1"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number31 index30 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">return</code> <code class="csharp keyword">new</code> <code class="csharp plain">BlockAir();</code></div><div class="line number32 index31 alt1"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div><div class="line number33 index32 alt2"><code class="csharp spaces"> </code> </div><div class="line number34 index33 alt1"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div></div></td></tr></tbody></table></div></div></div><div id="filler"> <div class="description" style="padding-top:0px"> <bodytext><p></p>
<p>So to find which chunk the block we need is contained in we divide the coordinates by the chunk size as a float then call the FloorToInt function which strips off everything beyond a multiple of the chunk size, then multiplying it by the size again gives us the coordinates of the chunk. I use the variable multiple so that the chunk size is a float when dividing because dividing two integers will give us trouble if they are negative. Then TryGetValue looks up the key in the dictionary and assigns the containerChunk with the result if found.</p>
<p>In the GetBlock function we create a chunk variable and try to assign the chunk we're looking for to it using the new GetChunk function. If it's successful and it returns something other than null we can call GetBlock in that chunk to get the block. We use the difference of the block coordinates and the chunk's which will give us the local location of the block. If the lookup fails we return a placeholder, something that we can use as a backup. Air works because it forces the side of the chunk to render everything so nothing is left unrendered but it does create unnecessary graphics work.</p>
<p>Now we have a little work on the other end in the Chunk, <strong>open the chunk script</strong> so we can look at the GetBlock function there, we left this unfinished before because we needed the world script to continue. What we'll do is check if the coordinates are within this chunk, if so return the chunk, otherwise link to the work script that can access the chunk that does contain it. </p>
<p> </p></bodytext></div> </div> <div class="codeblock"><div><div id="highlighter_114155" class="syntaxhighlighter csharp"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><div class="line number7 index6 alt2">7</div><div class="line number8 index7 alt1">8</div><div class="line number9 index8 alt2">9</div><div class="line number10 index9 alt1">10</div><div class="line number11 index10 alt2">11</div><div class="line number12 index11 alt1">12</div><div class="line number13 index12 alt2">13</div><div class="line number14 index13 alt1">14</div><div class="line number15 index14 alt2">15</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">public</code> <code class="csharp plain">Block GetBlock(</code><code class="csharp keyword">int</code> <code class="csharp plain">x, </code><code class="csharp keyword">int</code> <code class="csharp plain">y, </code><code class="csharp keyword">int</code> <code class="csharp plain">z)</code></div><div class="line number2 index1 alt1"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number3 index2 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">if</code><code class="csharp plain">(InRange(x) && InRange(y) && InRange(z))</code></div><div class="line number4 index3 alt1"><code class="csharp spaces"> </code><code class="csharp keyword">return</code> <code class="csharp plain">blocks[x, y, z];</code></div><div class="line number5 index4 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">return</code> <code class="csharp plain">world.GetBlock(pos.x + x, pos.y + y, pos.z + z);</code></div><div class="line number6 index5 alt1"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div><div class="line number7 index6 alt2"> </div><div class="line number8 index7 alt1"><code class="csharp spaces"> </code><code class="csharp comments">//new function</code></div><div class="line number9 index8 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">public</code> <code class="csharp keyword">static</code> <code class="csharp keyword">bool</code> <code class="csharp plain">InRange(</code><code class="csharp keyword">int</code> <code class="csharp plain">index)</code></div><div class="line number10 index9 alt1"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number11 index10 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">if</code> <code class="csharp plain">(index < 0 || index >= chunkSize)</code></div><div class="line number12 index11 alt1"><code class="csharp spaces"> </code><code class="csharp keyword">return</code> <code class="csharp keyword">false</code><code class="csharp plain">;</code></div><div class="line number13 index12 alt2"><code class="csharp spaces"> </code> </div><div class="line number14 index13 alt1"><code class="csharp spaces"> </code><code class="csharp keyword">return</code> <code class="csharp keyword">true</code><code class="csharp plain">;</code></div><div class="line number15 index14 alt2"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div></div></td></tr></tbody></table></div></div></div><div id="filler"> <div class="description" style="padding-top:0px"> <bodytext><p></p>
<p>I added the function InRange to check coordinates quickly.</p>
<p>While we're in the chunk script let's also add a function to set blocks in this chunk,</p>
<p> </p></bodytext></div> </div> <div class="codeblock"><div><div id="highlighter_832595" class="syntaxhighlighter csharp"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><div class="line number7 index6 alt2">7</div><div class="line number8 index7 alt1">8</div><div class="line number9 index8 alt2">9</div><div class="line number10 index9 alt1">10</div><div class="line number11 index10 alt2">11</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">public</code> <code class="csharp keyword">void</code> <code class="csharp plain">SetBlock(</code><code class="csharp keyword">int</code> <code class="csharp plain">x, </code><code class="csharp keyword">int</code> <code class="csharp plain">y, </code><code class="csharp keyword">int</code> <code class="csharp plain">z, Block block)</code></div><div class="line number2 index1 alt1"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number3 index2 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">if</code> <code class="csharp plain">(InRange(x) && InRange(y) && InRange(z))</code></div><div class="line number4 index3 alt1"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number5 index4 alt2"><code class="csharp spaces"> </code><code class="csharp plain">blocks[x, y, z] = block;</code></div><div class="line number6 index5 alt1"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div><div class="line number7 index6 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">else</code></div><div class="line number8 index7 alt1"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number9 index8 alt2"><code class="csharp spaces"> </code><code class="csharp plain">world.SetBlock(pos.x + x, pos.y + y, pos.z + z, block);</code></div><div class="line number10 index9 alt1"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div><div class="line number11 index10 alt2"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div></div></td></tr></tbody></table></div></div></div><div id="filler"> <div class="description" style="padding-top:0px"> <bodytext><p></p>
<p>It simply sets the block in the position described to the block provided and if it's not in range sends it to the world script. The world.SetBlock script is not created yet but it's fairly straight forward to imagine what it will do. So now in the world script lets add it:</p>
<p> </p></bodytext></div> </div> <div class="codeblock"><div><div id="highlighter_142175" class="syntaxhighlighter csharp"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><div class="line number7 index6 alt2">7</div><div class="line number8 index7 alt1">8</div><div class="line number9 index8 alt2">9</div><div class="line number10 index9 alt1">10</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">public</code> <code class="csharp keyword">void</code> <code class="csharp plain">SetBlock(</code><code class="csharp keyword">int</code> <code class="csharp plain">x, </code><code class="csharp keyword">int</code> <code class="csharp plain">y, </code><code class="csharp keyword">int</code> <code class="csharp plain">z, Block block)</code></div><div class="line number2 index1 alt1"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number3 index2 alt2"><code class="csharp spaces"> </code><code class="csharp plain">Chunk chunk = GetChunk(x, y, z);</code></div><div class="line number4 index3 alt1"><code class="csharp spaces"> </code> </div><div class="line number5 index4 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">if</code> <code class="csharp plain">(chunk != </code><code class="csharp keyword">null</code><code class="csharp plain">)</code></div><div class="line number6 index5 alt1"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number7 index6 alt2"><code class="csharp spaces"> </code><code class="csharp plain">chunk.SetBlock(x - chunk.pos.x, y - chunk.pos.y, z - chunk.pos.z, block);</code></div><div class="line number8 index7 alt1"><code class="csharp spaces"> </code><code class="csharp plain">chunk.update = </code><code class="csharp keyword">true</code><code class="csharp plain">;</code></div><div class="line number9 index8 alt2"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div><div class="line number10 index9 alt1"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div></div></td></tr></tbody></table></div></div></div><div id="filler"> <div class="description" style="padding-top:0px"> <bodytext><p></p>
<p>We just need to find the correct chunk and call SetBlock within it. After that we need to set update to true so that the chunk updates when it has the chance to show our new changes. Just setting this boolean isn't enough however so <strong>in the chunk script</strong> let's make chunks update when the flag is true:</p>
<p> </p></bodytext></div> </div> <div class="codeblock"><div><div id="highlighter_563876" class="syntaxhighlighter csharp"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><div class="line number7 index6 alt2">7</div><div class="line number8 index7 alt1">8</div><div class="line number9 index8 alt2">9</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="csharp spaces"> </code><code class="csharp comments">//Update is called once per frame</code></div><div class="line number2 index1 alt1"><code class="csharp spaces"> </code><code class="csharp keyword">void</code> <code class="csharp plain">Update()</code></div><div class="line number3 index2 alt2"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number4 index3 alt1"><code class="csharp spaces"> </code><code class="csharp keyword">if</code> <code class="csharp plain">(update)</code></div><div class="line number5 index4 alt2"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number6 index5 alt1"><code class="csharp spaces"> </code><code class="csharp plain">update = </code><code class="csharp keyword">false</code><code class="csharp plain">;</code></div><div class="line number7 index6 alt2"><code class="csharp spaces"> </code><code class="csharp plain">UpdateChunk();</code></div><div class="line number8 index7 alt1"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div><div class="line number9 index8 alt2"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div></div></td></tr></tbody></table></div></div></div><div id="filler"> <div class="description" style="padding-top:0px"> <bodytext><p></p>
<p>Now chunks can communicate over borders because requests for block data will be routed through the world class to the correct chunk. Seamless.</p>
<p>Our start function creates a bunch of chunks so that's in place but they're all empty so we'll fill them with some test blocks. Add to the CreateChunk function the following:</p>
<p> </p></bodytext></div> </div> <div class="codeblock"><div><div id="highlighter_239563" class="syntaxhighlighter csharp"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><div class="line number7 index6 alt2">7</div><div class="line number8 index7 alt1">8</div><div class="line number9 index8 alt2">9</div><div class="line number10 index9 alt1">10</div><div class="line number11 index10 alt2">11</div><div class="line number12 index11 alt1">12</div><div class="line number13 index12 alt2">13</div><div class="line number14 index13 alt1">14</div><div class="line number15 index14 alt2">15</div><div class="line number16 index15 alt1">16</div><div class="line number17 index16 alt2">17</div><div class="line number18 index17 alt1">18</div><div class="line number19 index18 alt2">19</div><div class="line number20 index19 alt1">20</div><div class="line number21 index20 alt2">21</div><div class="line number22 index21 alt1">22</div><div class="line number23 index22 alt2">23</div><div class="line number24 index23 alt1">24</div><div class="line number25 index24 alt2">25</div><div class="line number26 index25 alt1">26</div><div class="line number27 index26 alt2">27</div><div class="line number28 index27 alt1">28</div><div class="line number29 index28 alt2">29</div><div class="line number30 index29 alt1">30</div><div class="line number31 index30 alt2">31</div><div class="line number32 index31 alt1">32</div><div class="line number33 index32 alt2">33</div><div class="line number34 index33 alt1">34</div><div class="line number35 index34 alt2">35</div><div class="line number36 index35 alt1">36</div><div class="line number37 index36 alt2">37</div><div class="line number38 index37 alt1">38</div><div class="line number39 index38 alt2">39</div><div class="line number40 index39 alt1">40</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">public</code> <code class="csharp keyword">void</code> <code class="csharp plain">CreateChunk(</code><code class="csharp keyword">int</code> <code class="csharp plain">x, </code><code class="csharp keyword">int</code> <code class="csharp plain">y, </code><code class="csharp keyword">int</code> <code class="csharp plain">z)</code></div><div class="line number2 index1 alt1"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number3 index2 alt2"><code class="csharp spaces"> </code><code class="csharp comments">//the coordinates of this chunk in the world</code></div><div class="line number4 index3 alt1"><code class="csharp spaces"> </code><code class="csharp plain">WorldPos worldPos = </code><code class="csharp keyword">new</code> <code class="csharp plain">WorldPos(x, y, z);</code></div><div class="line number5 index4 alt2"><code class="csharp spaces"> </code> </div><div class="line number6 index5 alt1"><code class="csharp spaces"> </code><code class="csharp comments">//Instantiate the chunk at the coordinates using the chunk prefab</code></div><div class="line number7 index6 alt2"><code class="csharp spaces"> </code><code class="csharp plain">GameObject newChunkObject = Instantiate(</code></div><div class="line number8 index7 alt1"><code class="csharp spaces"> </code><code class="csharp plain">chunkPrefab, </code><code class="csharp keyword">new</code> <code class="csharp plain">Vector3(worldPos.x, worldPos.y, worldPos.z),</code></div><div class="line number9 index8 alt2"><code class="csharp spaces"> </code><code class="csharp plain">Quaternion.Euler(Vector3.zero)</code></div><div class="line number10 index9 alt1"><code class="csharp spaces"> </code><code class="csharp plain">) </code><code class="csharp keyword">as</code> <code class="csharp plain">GameObject;</code></div><div class="line number11 index10 alt2"><code class="csharp spaces"> </code> </div><div class="line number12 index11 alt1"><code class="csharp spaces"> </code><code class="csharp comments">//Get the object's chunk component</code></div><div class="line number13 index12 alt2"><code class="csharp spaces"> </code><code class="csharp plain">Chunk newChunk = newChunkObject.GetComponent<Chunk>();</code></div><div class="line number14 index13 alt1"><code class="csharp spaces"> </code> </div><div class="line number15 index14 alt2"><code class="csharp spaces"> </code><code class="csharp comments">//Assign its values</code></div><div class="line number16 index15 alt1"><code class="csharp spaces"> </code><code class="csharp plain">newChunk.pos = worldPos;</code></div><div class="line number17 index16 alt2"><code class="csharp spaces"> </code><code class="csharp plain">newChunk.world = </code><code class="csharp keyword">this</code><code class="csharp plain">;</code></div><div class="line number18 index17 alt1"><code class="csharp spaces"> </code> </div><div class="line number19 index18 alt2"><code class="csharp spaces"> </code><code class="csharp comments">//Add it to the chunks dictionary with the position as the key</code></div><div class="line number20 index19 alt1"><code class="csharp spaces"> </code><code class="csharp plain">chunks.Add(worldPos, newChunk);</code></div><div class="line number21 index20 alt2"><code class="csharp spaces"> </code> </div><div class="line number22 index21 alt1"><code class="csharp spaces"> </code><code class="csharp comments">//Add the following:</code></div><div class="line number23 index22 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">for</code> <code class="csharp plain">(</code><code class="csharp keyword">int</code> <code class="csharp plain">xi = 0; xi < 16; xi++)</code></div><div class="line number24 index23 alt1"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number25 index24 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">for</code> <code class="csharp plain">(</code><code class="csharp keyword">int</code> <code class="csharp plain">yi = 0; yi < 16; yi++)</code></div><div class="line number26 index25 alt1"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number27 index26 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">for</code> <code class="csharp plain">(</code><code class="csharp keyword">int</code> <code class="csharp plain">zi = 0; zi < 16; zi++)</code></div><div class="line number28 index27 alt1"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number29 index28 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">if</code> <code class="csharp plain">(yi <= 7)</code></div><div class="line number30 index29 alt1"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number31 index30 alt2"><code class="csharp spaces"> </code><code class="csharp plain">SetBlock(x+xi, y+yi, z+zi, </code><code class="csharp keyword">new</code> <code class="csharp plain">BlockGrass());</code></div><div class="line number32 index31 alt1"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div><div class="line number33 index32 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">else</code></div><div class="line number34 index33 alt1"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number35 index34 alt2"><code class="csharp spaces"> </code><code class="csharp plain">SetBlock(x + xi, y + yi, z + zi, </code><code class="csharp keyword">new</code> <code class="csharp plain">BlockAir());</code></div><div class="line number36 index35 alt1"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div><div class="line number37 index36 alt2"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div><div class="line number38 index37 alt1"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div><div class="line number39 index38 alt2"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div><div class="line number40 index39 alt1"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div></div></td></tr></tbody></table></div></div></div><div id="filler"> <div class="description" style="padding-top:0px"> <bodytext><p></p>
<p>This will give us a little content to see that it's working so that when you run it you should be able to see something like this:</p>
<p> </p></bodytext></div> </div> <img src="./Part 3_files/voxsw.png"> <div id="filler"> <div class="description"> <bodytext><p></p>
<p>Cool! Last of all let's also add a function to remove chunks which we'll need later when we're loading and unloading our infinite terrain:</p>
<p> </p></bodytext></div> </div> <div class="codeblock"><div><div id="highlighter_286976" class="syntaxhighlighter csharp"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><div class="line number7 index6 alt2">7</div><div class="line number8 index7 alt1">8</div><div class="line number9 index8 alt2">9</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="csharp spaces"> </code><code class="csharp keyword">public</code> <code class="csharp keyword">void</code> <code class="csharp plain">DestroyChunk(</code><code class="csharp keyword">int</code> <code class="csharp plain">x, </code><code class="csharp keyword">int</code> <code class="csharp plain">y, </code><code class="csharp keyword">int</code> <code class="csharp plain">z)</code></div><div class="line number2 index1 alt1"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number3 index2 alt2"><code class="csharp spaces"> </code><code class="csharp plain">Chunk chunk = </code><code class="csharp keyword">null</code><code class="csharp plain">;</code></div><div class="line number4 index3 alt1"><code class="csharp spaces"> </code><code class="csharp keyword">if</code> <code class="csharp plain">(chunks.TryGetValue(</code><code class="csharp keyword">new</code> <code class="csharp plain">WorldPos(x, y, z), </code><code class="csharp keyword">out</code> <code class="csharp plain">chunk))</code></div><div class="line number5 index4 alt2"><code class="csharp spaces"> </code><code class="csharp plain">{</code></div><div class="line number6 index5 alt1"><code class="csharp spaces"> </code><code class="csharp plain">Object.Destroy(chunk.gameObject);</code></div><div class="line number7 index6 alt2"><code class="csharp spaces"> </code><code class="csharp plain">chunks.Remove(</code><code class="csharp keyword">new</code> <code class="csharp plain">WorldPos(x, y, z));</code></div><div class="line number8 index7 alt1"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div><div class="line number9 index8 alt2"><code class="csharp spaces"> </code><code class="csharp plain">}</code></div></div></td></tr></tbody></table></div></div></div><div id="filler"> <div class="description" style="padding-top:0px"> <bodytext><p></p>
<p>This takes the coordinates of a chunk and removes it from the world and from our dictionary freeing up space for chunks closer to the player.</p>
<p>With that we'll call this part complete, now we can create any number of chunks in any location and remove them again. In the next part we'll look into modifying the terrain using set block and getting block positions in the scene from the camera's view.</p>
<p><a href="https://web.archive.org/web/20150214125646/http://alexstv.com/index.php/posts/unity-voxel-block-tutorial-pt-2" class="inline_button" style="background-color:#2D9AE3">Tutorial part 2</a><a href="https://web.archive.org/web/20150214125646/http://alexstv.com/downloads/voxeltut3.zip" class="inline_button" style="background-color:#2D9AE3">Download scripts so far</a>
<a href="https://web.archive.org/web/20150214125646/http://alexstv.com/index.php/posts/unity-voxel-block-tutorial-pt-4" class="inline_button" style="background-color:#2D9AE3">Tutorial part 4</a><br><br></p>
<p><a href="https://web.archive.org/web/20150214125646/https://twitter.com/stv_alex" class="inline_button" style="background-color:#77B1D1">Follow me on twitter</a><a href="https://web.archive.org/web/20150214125646/https://plus.google.com/+AlexandrosStavrinou/posts" class="inline_button" style="background-color:#D73D32">Add me on Google+</a><br><br></p>
</bodytext>
</div>
</div>
<section class="yspace"></section>
<div class="datestamp">
<stamptext>29th Dec, 2014</stamptext>
</div>
<div class="authorstamp">
<stamptext>Alex</stamptext>
</div>
<section class="yspace"></section>
</div>
<div class="post">
<div id="filler">
<bodytext>
<form id="comment" class="commentform commentbox" method="post" action="https://web.archive.org/web/20150214125646/http://alexstv.com:80/index.php/posts/unity-voxel-block-tutorial-pt-3#comment">
<p class="name">
<label for="name">Your name:</label>
<input name="name" id="name" type="text" placeholder="Your name" value=""> </p>
<p class="email">
<label for="email">Your email address:</label>
<input name="email" id="email" type="email" placeholder="Your email (won’t be published)" value=""> </p>
<p class="textarea">
<label for="text">Your comment:</label>
<textarea name="text" id="text" placeholder="Your comment"></textarea> </p>
<p class="submit">
<button class="btn" type="submit">Post Comment</button> </p>
</form>
</bodytext>
</div>
</div>
</article>
</div>
<div class="bg1">
<footer class="wrapper">
<footer class="footer">
<div class="fiftyfifty" style="padding:10px;"><bodytext>© 2015 AlexStv. All rights reserved.</bodytext></div>
<div class="fiftyfifty"><form id="search" action="https://web.archive.org/web/20150214125646/http://alexstv.com:80/index.php/search" method="post">
<bodytext>Search: </bodytext>
<input type="search" style="width:300px; padding:10px; border: 1px solid #e8e8e8;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;" id="term" name="term" placeholder="Type here and hit enter to search" value=""></form></div>
</footer>
</footer>
</div>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//web.archive.org/web/20150214125646/http://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-58007562-1', 'auto');
ga('send', 'pageview');
</script>
<!--
playback timings (ms):
LoadShardBlock: 146.883 (3)
esindex: 0.008
captures_list: 193.894
CDXLines.iter: 14.283 (3)
PetaboxLoader3.datanode: 163.338 (4)
exclusion.robots: 0.483
exclusion.robots.policy: 0.467
RedisCDXSource: 27.662
PetaboxLoader3.resolve: 43.895
load_resource: 85.443
--></body></html>