Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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
1
Question by tobinp93 · Apr 11, 2018 at 11:44 PM · unity 2dtilemapnavigation

Unity 2d navmesh for a tilemap

Hello, I have made a 2d world in unity using tilemap. My grid has two tilemaps, one for the walkable space (ground), and another for the walls (trees), which has a tilemap collider. I can place a controllable character in my map and collide with walls as I walk around the board. I am now trying to create a navigation mesh so I can give my character the ability to click to move around the board. I have heard that the unity navigation mesh does not work with unity 2d, is this still the case? If so, I have already rotated my grid and tilemaps to be aligned with the xz plane. Now that my playing field is aligned with the xz plane, is there a way to generate a navigation mesh onto my grid and these tilemaps? I am aware that I can make an invisible 3d world that aligns with my tilemaps for the floor and walls, but I am wondering if there is a simpler solution.

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
1

Answer by beanie4now · Aug 19, 2018 at 07:19 PM

EDIT @Compguru910 I have been working on this for the past month and have everything running smoothly. Here's how to do it.

  1. Start new project as 2D

  2. Import the following components https://github.com/Unity-Technologies/NavMeshComponents https://github.com/Unity-Technologies/2d-extras

  3. Add a new 3D plane to the scene and rotate it -90 on X axis

  4. NEVER i repeat NEVER open the "navigation" tab at any time

  5. Add a "navmesh surface" component to the Plane. Bake it... it should turn blue.

  6. Create a desired EMPTY GAMEOBJECT prefab with a child that you add navmesh agent and another that you add sprite and animation to (i recommend an empty parent then a separate nav and sprite child. The sprite will want to rotate to lock onto the navmesh so just write an update transform that makes the sprite follow the nav agent)

  7. Create a desired obstacle prefab as well then add the component "NavMeshObstacle" MAKE SURE the obstacle has the box "carve" checked

  8. Make the obstacle a prefab by dragging it into the project window below.

  9. Right click the project window, select "Create", "Brushes", "Prefab Brush"

  10. Set length to 1 then drag in your prefab obstacle

  11. Paint a few onto a tilemap and then when you click on the plane you should see holes in the navmesh surface.

  12. Add some code to move around like such void Update () { if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { if (!EventSystem.current.IsPointerOverGameObject() && canMove == true){ nav.SetDestination(hit.point); } } } }

Comment
Add comment · Show 7 · 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 beanie4now · Aug 19, 2018 at 07:47 PM 0
Share

The prefab brush can be found here in the 2-D Extras.

avatar image beanie4now · Aug 19, 2018 at 07:57 PM 0
Share

And of course below all the tilemaps I have a 3D plane that I can just set as a navigation static and bake once all of the prefab tiles have been placed.

avatar image Compguru910 · Oct 14, 2018 at 06:24 AM 0
Share

How exactly are you using that plugin? I downloaded and imported to my project, but I'm not seeing editor windows added to use the new functions. Any insight would be greatly appreciated.

avatar image beanie4now Compguru910 · Oct 14, 2018 at 06:10 PM 0
Share

I edited my Answer with a step by step guide as to how I have $$anonymous$$e running now. Hope it helps!

avatar image nantoaqui · Jun 03, 2019 at 08:08 PM 0
Share

It works!! @beanie, how do you cleanup those obstacle prefabs?

avatar image beanie4now nantoaqui · Jun 03, 2019 at 09:30 PM 0
Share

I haven't used Unity in a while but I think there are 2 ways. The erase button in the tile map window may work... use like a brush. If not the prefabs will be in the hierarchy as children of the tilemap you placed them in. You can select them from there if all else fails.

avatar image nantoaqui beanie4now · Jun 04, 2019 at 06:23 PM 0
Share

I disabled the mesh renderer and it did the trick! thanks!

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.

Follow this Question

Answers Answers and Comments

78 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

Related Questions

Tilemap - How to merge more tilemaps into one array 1 Answer

How to make 2D walls Transparent when the player or enemy is behind it. 1 Answer

How can I get the world position of a Tile? 2 Answers

Lightweight rp not working when running game 1 Answer

How to use TileMap.GetInstantiatedObject? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges