# Script for creating 2d map of non-random tiles

Hello,

I’m working on creating a 2D tiled map (for practice) and my questions is: Can I make a 2d-tiled map using a script (not a plug-in) of non-random tiles?

In other words: how do I tell unity to put “grass” sprite from (1,2) to (1,10), “sand” sprite from (2,2) to (2,10), etc.

I already did the 2D roguelike tutorial and learned how to upload sprites into the engine. The problem is that I want to make a map made of tiles in a fixed (not random) order. I Went over the tutorials but couldn’t find nothing relevant.

I consider myself as a beginner and I don’t know how to write the correct script, so if someone could upload an example (even for 3x3 map with 2 types of tiles) it’ll be great.

Last, I already looked up for a solution, but everything I found concerned using plug-ins. As I’ve said, I want to practice it using a script.

Thanks!

Tried the following but it has a problem with “y”
(In the section:
for(int x = 0)
{
if(int y = 0)
{
GameObject toInstantiate = FreshWater;
}

``````	if(int y = 1)
{
GameObject toInstantiate = LightGrass;
}
}
``````

)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Random = UnityEngine.Random;
using System;
namespace completed
{

public class LocationA : MonoBehaviour
{
[Serializable]
public class Count
{
public int minimum; // Minimum value for our Count class.
public int maximum; //Maximum value for our Count class.

``````	//Assignment constructor.
public Count (int min, int max)
{
minimum = min;
maximum = max;
}
}
public int columns = 10;
public int rows = 10;
public GameObject[] FreshWater;
public GameObject[] LightGrass;

private List <Vector3> gridPositions = new List <Vector3> (); // possible locations for the tiles

for(int x = 0)
{
if(int y = 0)
{
GameObject toInstantiate = FreshWater;
}

if(int y = 1)
{
GameObject toInstantiate = LightGrass;
}
}
``````

}
}