• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Descalium · Feb 05, 2019 at 10:10 PM · programmingtilemaptilesisometric

How do you get the tile on which a gameObject is standing on Isometric Tilemap ?

Hi everybody !

I'm trying to use the isometric z as y tilemap and create a character on it. I want that the character can snap on the grid case exactly like the tile. But... It work in a way that i can't understand.

alt text

alt text

Why do they have different position ? How can i get the tile (and it position) on the gameObject is ? I'm so confuse right now.

Can someone (maybe) explain me, how do we create a lambda character and make it move on the grid ? (with taking the tile's position where he is standing on ?)

Thank you for reading,

grid.png (174.4 kB)
character.png (196.2 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
5
Best Answer

Answer by z_orochii · Feb 06, 2019 at 06:20 AM

If you know the exact grid position (the one that shows at the first screen you posted), you can use GridLayout.CellToWorld to, as the method name suggests, convert a cell position into a world position. This one receives a Vector3Int with the position relative to the grid.


In order to use CellToWorld you must have a reference to the Grid object (like the one tilemaps use). And if you want to know the current (closest) cell where an object in the world is, you can use the opposite method: GridLayout.WorldToCell. This one receives as parameter a Vector3 corresponding to a point in the world space.


Hope it helps!

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Descalium · Feb 06, 2019 at 10:50 AM 0
Share

Thank you very much. Actually, it work perfectly with this kind of code :

 Vector3Int lPos = grid.WorldToCell(player.transform.position);
             Debug.Log("name : " + tilemap.GetTile(lPos).name + " & position : " + lPos);



Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

113 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Isometric grid snapping 0 Answers

Interact with tile / triggering script 1 Answer

How to count Tiles in a sourinding Area around an Object? 1 Answer

Can isometric tiles be rotated? 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges