Hello Guest

Author Topic: How to move tk2dTileMap  (Read 5011 times)

DJVDJV

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 30
    • View Profile
How to move tk2dTileMap
« 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

LaserDinosaur

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: How to move tk2dTileMap
« Reply #1 on: October 04, 2015, 07:49:07 pm »
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:



DJVDJV

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: How to move tk2dTileMap
« Reply #2 on: October 04, 2015, 09:06:12 pm »
How I should do this in code wise?

LaserDinosaur

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: How to move tk2dTileMap
« Reply #3 on: October 04, 2015, 10:19:22 pm »
I'd suggest looking into some tutorials on the transform.position 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:

Code: [Select]
GetComponent<tk2dTileMap>().Build();

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: How to move tk2dTileMap
« Reply #4 on: October 05, 2015, 11:13:13 am »
At runtime, you should move both the tilemap and the tilemap render data

Code: [Select]
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.