We want our enemies to spawn at the top of the viewport's background. At spawn, the Y value can be the same for each of the enemies, but we want a random X value.
First of all, let's open our Game scene.
Our enemies will be nested in a container placed at the top left-hand corner of our background in order to have the {0, 0} positioned at the top left-hand corner of the viewport.
First, let's create our enemies holder by performing the following steps:
Select our Viewport GameObject and perform the following steps:
Create a new child by pressing Alt + Shift + N.
Rename this new child as
Enemies
.
Attach Anchor to it by navigating to NGUI | Attach. Then perform the following steps:
Drag our Background from Viewport into the Container field.
Set its Side parameter to TopLeft.
Ok, we now have our enemies container in which we will instantiate our Enemy prefab.