Game Development Reference
In-Depth Information
In the Project panel, open the Assets ➤ Prefab folder, then assign the Land Mine prefab to the
Prefab property of the RegularLandMinePositions script in the Inspector. Save the scene.
Playtest to see the pattern, in which each successive row the land mine is positioned higher than in
the previous one. This zone becomes solid land mines by the end, impossible to cross (Figure 10-8 ).
Figure 10-8. Prefab land mines distributed in a regular pattern using a script
Change the following line of code:
for (var i : int = 0; i < numberLength; i++)
to
for (var i : int = 0; i < numberLength/2; i++)
and the line:
zPos = zPos + 1;
to
zPos = zPos + 2;
Save the script and playtest. The first code change means half as many rows were created, while the
second places them 2 units apart instead of 1. Experiment with changing the number and spacing of
rows, and the number and spacing of prefabs in each row. Arrange it how you like it best, until you
have two alternatives of random and regularly spaced for land mine placement in this zone that can
easily be alternated by enabling and disabling the respective scripts.
 
Search WWH ::




Custom Search