2D Toolkit Forum
2D Toolkit => Support => Topic started by: DJVDJV on October 04, 2015, 01:37:44 pm
-
Hellos,
How I can set whole tk2dTileMap place in world. Like I have 2 different map but I want their coordinate 1,1 be in different place in world.
Y, Heikki
-
If you're just trying to shift the entire tilemap, you can highlight "Tilemap" in the hierarchy (moving "Tilemap Render Data" wont do anything, it will reset when you hit play) and then move the entire thing using the editor position handles:
(https://dl.dropboxusercontent.com/u/20830426/movingTilemap.png)
-
How I should do this in code wise?
-
I'd suggest looking into some tutorials on the transform.position (http://docs.unity3d.com/ScriptReference/Transform-position.html) property. Once you've set the tilemap to the position you want, you can then call the following to rebuild the tilemap at the new location:
GetComponent<tk2dTileMap>().Build();
-
At runtime, you should move both the tilemap and the tilemap render data
GetComponent<tk2dTielmap>().transform.position = newPosition;
GetComponent<tk2dTielmap>().renderData.transform.position = newPosition;
No need to call build in this case, the above will be way more efficient.