Hi there guys, i want to make a TILE (or its sprite) TREMBLE during a short time, i usually do that by adding a random x/y to GameObject positions but as a tile can only be placed in a cell position is not possible to add just some decimals to it
So i tried with it’s SPRITE (Tile.sprite) but the sprite has no position property, any suggestions?
Two obvious ways I can think of are to either animate the tile, or to fake it.
Faking it would just mean making a game object that looks like the tile and overlaps it and move it like you usually would, then destroy it when not needed. You can also temporarily remove the tile from the tilemap while this is occurring, then add it back when you get rid of the fake. If this is a common enough occurrence, you could preserve the object and just disable it instead, moving it and altering its appearance as needed to any new shaking tile.
because the tile is not a real sprite, if you are using tilemaps the tile is drawn on a mesh and you either move the whole map or you paint over the tile. the tiles on a tilemap are not single objects but form a collective and all you can do is paint it over, and you are restricted to the cells. Its because of this system that tilemaps dont lag your game, if you try to use game objects as tiles your framerate will suffer greatly unless you use it sparingly
Tiles do have a transform and if you want to change it you grab its transform Matrix4x4 then use its trs function to set new values Unity - Scripting API: Matrix4x4.TRS its a bit of round about way but it is possible
edit realized it might be better to give an example of moving a tiles position.
DestructibleTile dt = Instantiate(resourceData[i].resourceTile) as DestructibleTile;
float xValue = (offsetNoiseX.GetSimplexFractal(x, y) + 1)/2;
float yValue = (offsetNoiseY.GetSimplexFractal(x, y) + 1)/2;
var m = dt.transform;
m.SetTRS(new Vector3(xValue, yValue, 0), Quaternion.Euler(0f, 0f, 0f), Vector3.one);
dt.transform = m;
dt.flags = TileFlags.LockAll;
dt.StartUp(new Vector3Int(x, y, 0), dt.tileMap, dt.gameObject);
resourceMap.SetTile(new Vector3Int(x, y, 0), dt);
They thanks for your reply but after days trying to achieve it i’m not able to… with your example i don’t have “DestructibleTile”, neither “GetSimplexFractal” and so on…