U
U
Uncle Bogdan2021-10-03 12:52:08
Unity
Uncle Bogdan, 2021-10-03 12:52:08

Tiled generation not working?

Wrote this code:

private void GenerateTiles()
    {
        for(int i = 0; i < _tilesCount; i++)
        {
            if(i == 0)
            {
                _currentTile = Instantiate(_startTile, _parent);
            }
            else
            {
                var randomTile = _tiles[Random.Range(0, _tiles.Length)];

                _currentTile = Instantiate(randomTile, _currentTile.EndPoint.position - randomTile.StartPoint.localPosition, Quaternion.identity, _parent);
            }
        }
    }


But it doesn't spawn correctly:

61597c93bc72a674062779.png

Here's the tile:

61597d45b5d21288928322.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BFGunner, 2021-10-05
@motkot

During generation, you subtract local.position from position to determine the location. I feel like there's a bug here. And the vertical offset is also from there, you should consider only one position coordinate.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question