Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved Hey, i have so problems with the Instantiate function

Discussion in 'Scripting' started by tymonekdeville, May 2, 2023.

  1. tymonekdeville

    tymonekdeville

    Joined:
    May 2, 2023
    Posts:
    3

    using UnityEngine;

    public class Grid{

    private int width;
    private int height;
    private GameObject thing;
    private int[,] gridArray;

    public Grid(int width, int height, GameObject thing, float distance){
    this.width = width;
    this.height = height;
    this.thing = thing;

    gridArray = new int[width,height];

    for (int x=0; x<gridArray.GetLength(0); x++){
    for (int y=0; y<gridArray.GetLength(1); y++){
    Instantiate(thing, new Vector3(distance * x, 0, distance * y), thing.transform.rotation);
    }
    }

    }

    }

     
  2. RadRedPanda

    RadRedPanda

    Joined:
    May 9, 2018
    Posts:
    1,646
    So, what's the problem?
     
    Bunny83 likes this.
  3. tymonekdeville

    tymonekdeville

    Joined:
    May 2, 2023
    Posts:
    3
    It gives me an error, it says that "The name Instantiate does not exist in the current context"
     
  4. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    2,605
    Bunny83 likes this.
  5. tymonekdeville

    tymonekdeville

    Joined:
    May 2, 2023
    Posts:
    3
    Yoreki likes this.