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
0
Question by kkrac · Jul 17, 2017 at 02:16 AM · navmeshnavmeshagentpathfindingartificial intelligence

Artificial intelligence - Find way through changing path

The NPC starts off at the yellow circle and the goal is for it to make all its way to the green circle.

The map consists of platforms formed by 4 circles of the same color (the yellow and green where colored differently to make it clear they are the starting point and the destination, respectively). A platform can be rotated in angles of 90 degrees counter-clockwise. The little black squares in the map are bridges that connect platforms. The NPC can walk across them to move from one platform to another.

The NPC can't move from one circle to another (not event circles that are part of the same platform) unless there's a bridge connecting them.

So the 2 only movements are: rotate a platform (adjacent circles of same color) and walk across a bridge.

The NavMesh is formed by all circles and bridges.

alt text alt text

The challenge is what path the NPC has to take, given that the destination might not be right away reachable since platforms have to be rotated for the NPC to be able to move forward.

The way I thought (but couldn't make it work yet) was to:

1) At the yellow circle Call "SetDestination" passing the position of the green circle.

2) Call CalculatePath:

  • if the Pathstatus is "Complete", then he can directly walk to destination.

  • if the Pathstatus is "Partial" then I know that the platform has to be rotated. When platform is rotated, the NPC might start moving (if there's a bridge to the adjacent platform) reaching eventually the destination (done), or getting stuck again (moment to rotate platform again).

3) If NPC hasn't reached destination, go back to 2)

Maybe I'm overcomplicating it.

Is this the right way to go? Is it more complicated than I think?

untitled2.png (8.3 kB)
untitled3.png (16.0 kB)
Comment
Add comment · Show 2
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 Jwizard93 · Jul 17, 2017 at 05:18 AM 0
Share

Theres always a path unless you don't alternate red blue red blue as you have in the image.

Create an empty moves list - push an int that is the number of times the current group must rotate until he touches the next group along with an int representing how much the next group will need to rotate til he can move on. Theres not even that many cases so you could easily get a $$anonymous$$imum moves solution as well by brute force.

I might be missing the rules here i seems pretty simple. You said he can only rotate things of the same color.. but then you said at the beginning he rotates the first four so I'm thinking he rotates groups of four that are the same color. ins$$anonymous$$d of 2 and 2 from different groups or all groups of the same color at once.

avatar image kkrac Jwizard93 · Jul 17, 2017 at 06:09 AM 0
Share

Thanks @Jwizard93 I edited the original post to clarify.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by NorthStar79 · Jul 17, 2017 at 06:14 AM

you can not rotate baked nav mesh. so eighter you need to use some another pathfinding solutions (like A* asset on asset store) or not use a navmesh at all and try a workaround by firing lots of raycast or something idk.

Comment
Add comment · 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
0

Answer by kkrac · Jul 17, 2017 at 01:28 PM

@NorthStar79 I did a small "hack" for that: I marked the circles as static, baked the mesh, and then unmarked the "static" check of the circles so that they can move. Since there's always a circle in the position where a part of the mesh is, it works Ok.

If it happens I forgot to add a circle to the path when building the scene, I have to mark all circles again as static after adding the circle I missed, and re-bake the mesh. Not that big of a hassle since I just need to mark the circle's parent empty gameObject and not go one by one.

Maybe not the best solution, but it did it's job for what I was looking for.

Comment
Add comment · 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

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

74 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

Related Questions

Use Fog of War to Restrict NavMesh Per-Agent 0 Answers

Horde of NavMeshAgents - stops to recalculate path. 4 Answers

How do I fix two NavMeshAgents fighting for the same position? 1 Answer

Recentering an infinite world that has a NavMesh. 0 Answers

How to check if Navmesh finished baking realtime ( in playmode ) ? 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