Create a repeated map automatically

Hi !

I am new with unity and programmation with object and I have a little problem.

I would like to create a 2d game where the player is falling in hole.

So I want to repeat the map until the player die.

I already create a gameObject “Map” who have to be repeated and a gameobject who use the script.

here is my script :

using UnityEngine; using System.Collections;

public class CréationMap : MonoBehaviour {

public GameObject MapPrefab;

// Use this for initialization 	void Start () { 		InvokeRepeating ("createObstacle", 0.2f, 0.2f);
    

} 	 	// Update is called once per frame

void Update () {
Instantiate(MapPrefab);

    int i = 1;
    MapPrefab.transform.position = new Vector2(0, -1.78f*i);
    i++;
} 

}

It doesn’t work correctly, it create all the copy at the same place. But i want to change the Y position on each copy.
Could you help me please ?

Thanks.

I find the error, i’m just stupid I init “i” on each frames ._.