Instantiating multiple prefabs with animations all appear at 0,0,0


I was wondering if anyone had any insight into my problem.

I've created a prefab of a 2d wave with a simple animation attached. I want to create a number of them in a row to create a curtain along the bottom of my screen, however they all appear at the center of the world, rather than the position along the X axis that I specify...

My simple enough code is:

var seaPrefab : GameObject;
var counter: int = 0;
var depthVariable: int = 0.2;

function Update () {


        var seaLayerInstance : GameObject = Instantiate(seaPrefab, Vector3(counter*2, 0, depthVariable), transform.rotation);

        depthVariable *= -1;



I've also put my animated prefab inside an empty GO hoping to offset the prefabs that way, but that has also not worked.

Any help would be greatly appreciated!!



Check the inspector to make sure your world units are far enough apart. Have you tried something like:

seaLayerInstance.transform.position = Vector3(....);

`Input.GetAxis("Horizontal")` does not allow you to pick a position. It is always between -1 and 1, and represents how long you have been holding down Left/Right arrow (1 means you've held Right-arrow long enough to be sliding or turning at full speed.) It's for moving the player.

This Unity doc has an example of making a wall, in Start. Could adapt it for your line:

Also, depthVariable should be a float (since you're using 0.2.)

The problem was I wasn’t using the prefab as a child of an empty GO as I had attempted to do.