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 lhk · May 04, 2016 at 08:41 PM · c#2dperformancepathfindingstrategy

2D Pathfinding: how to create navMesh

I'm developing a small 2D top-down strategy game as a hobby. Well at least I would like to, right now I'm only playing around with Unity.

I think that the first thing to implement is pathfinding. There are existing packages but I would like to roll my own. Although I'm new to unity, I'm not new to programming.

Here is an implementation of A* I did in python: https://youtu.be/pwevEL57c7Q

The algorithm itself is no problem, I could translate it to C# quite easily. The setup of the graph is difficult. And this is were I need feedback. I've got a few ideas, but I want to avoid investing time in something that is a dead-end.

  1. Create an evenly spaced grid of nodes, create edges between neighbouring nodes. Each obstacle "registers" itself with the graph. The graph looks at the position and the size of the object and deletes intersecting nodes.

  2. Create an empty graph. Each obstacle "registers" itself with the graph. The graph looks at the obstacle, queries its collider, creates a node for each edge of the collider and then loops through all existing nodes. For each pair of existing/new node the algorithm checks if there is something in the way, if not it adds an edge

  3. Go overboard: Create an adaptively spaced grid (something like a quadtree). Start with just one square. If an obstacle is added, subdivide recursively. Stop the recursion when the ratio of obstacle/square is acceptable. Add nodes to each quad. Remove intersections with obstacles.

Each has its advantages and disadvantages.

  1. Produces a huge number of nodes. The grid should be very fine-grained. This could waste a lot of memory. But creating edges is easy, since you know the spatial setup and know which nodes are potential neighbours.

  2. Is very cheap to begin with. But as you add obstacles the performance will seriously degrade. For each new node, each existing node has to be checked for a clear path. I don't think that this is feasible.

  3. Seems overkill for such a "simple" task. I've never implemented adaptive mesh refinement. Would surely be interesting but that can't be standard for every game, can it ?

Can you point me in the right direction ? Did you implement pathfinding for your game, too ? Where are the strengths and weaknesses of unity3d in terms of this task. For example: How many raycasts can I do per second in a complex scene with dozens of objects ?

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

0 Replies

· Add your reply
  • Sort: 

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

166 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 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

Distribute terrain in zones 3 Answers

Help with my 2d pathfinding 0 Answers

Choppy Character Movement Unity 2D 0 Answers

When the development team will implement 2D Navmesh? 0 Answers

How to compare several distances? 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