Rebuild Roguelike with other sprite sheet size
I follow the Roguelike tutorial series. I've trying to rebuild it my own to learn most of it.
However I'm at the "BoardManager" now and instead of a nice board like in the tutorial I get something kind of spread tiles.
I see that my sprite sheet is 1024x1024 instead of 256x256 like in the tutorial. How can I tell Unity to expand my sprite so they follow each other?
Here my BoardManager script:
using UnityEngine;
using System;
using System.Collections.Generic; //Allows us to use Lists.
using Random = UnityEngine.Random; //Tells Random to use the Unity Engine random number generator.
public class BoardManager : MonoBehaviour {
public int columns = 8;
public int rows = 20;
public GameObject[] backgroudTiles;
public GameObject[] undergroundTiles;
private Transform boardHolder;
private List<Vector3> gridPositions = new List<Vector3>();
private void InitializeList()
{
gridPositions.Clear();
for (int x = 0; x < columns; x++) {
for (int y = 0; y < rows; y++) {
gridPositions.Add(new Vector3(x,y,0f));
}
}
}
private void BoardSetup()
{
boardHolder = new GameObject("Board").transform;
for (int x = 0; x < columns; x++) {
for (int y = 0; y < rows; y++) {
// Background tiles
// randomly choose a background tile
GameObject toInstantiate = backgroudTiles[Random.Range(0, backgroudTiles.Length)];
// instantiace it
GameObject instance = Instantiate(toInstantiate, new Vector3(x,y,0f), Quaternion.identity) as GameObject;
// parent it to the board holder
instance.transform.SetParent(boardHolder);
}
}
}
private Vector3 RandomPosition()
{
int randomIndex = Random.Range(0, gridPositions.Count);
Vector3 randomPosition = gridPositions[randomIndex];
gridPositions.RemoveAt(randomIndex);
return randomPosition;
}
//SetupScene initializes our level and calls the previous functions to lay out the game board
public void SetupScene (int level)
{
BoardSetup();
InitializeList();
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
roguelike-board.jpg
(154.5 kB)
Comment
Answer by rohn_john · Sep 28, 2016 at 06:01 AM
https://forum.unity3d.com/threads/2d-roguelike-q-a.297180/page-2
please see TizzyTool's reply(#53)
by default 100pixel = 1unit