I want to use the tilemaps and pallets as an In-Game feature to create maps in real time. I am very basic at coding and I haven’t been able to find any tutorials for this.
This is what I have:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;
public class Paint_Tile : MonoBehaviour
{
public Tile brush;
public Tilemap currentTilemap;
public KeyCode mouseLeft;
//Paint a tile-cell with the selected tile
private void Update()
{
// get current grid location
Vector3Int currentCell = currentTilemap.WorldToCell(transform.position);
// if a cell is selected with mouseleft
if (Input.GetKey(mouseLeft))
{
// paint the selected tile with the brush
currentTilemap.SetTile(currentCell, brush);
}
}
}
It just chooses the same vector3Int everytime (-11, 1, 0) and places just the one brush there. What am I doing wrong?