Script instantiation always same position

Hello guys,

i try to instantiate a Prefab at a certain position depending on how many instances already were instanciated. The project is in 2D.

public GameObject projectObj;
float y_pos = 0;

public void NewButton()
        y_pos += 10;
        GameObject inst = Instantiate(projectObj, new Vector3(100, y_pos, 0), Quaternion.identity);

Goal: Instanciate iteratively by button pressing at different y positions = n*10.
Problem: Instantiation always at (0, 0) of parent object. I read many threads but did not find a similar problem. Thanks for your help in advance :slight_smile:

PS: tried to change from Vector3 to Vector2 and played around with datatypes but never changed behaviour: even using Vector3(1000,1000,0) or Vector2(1000,1000) delivering the same result so i must have a misunderstanding here.


Since nothing seemed wrong I plugged in the code into a test scene, and it worked out very well.
How are you calling the method? I called it in the Update method and it worked just fine.