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 OctoMan · Apr 26, 2018 at 09:35 PM · aiastarpath-findingpathing

Astar Pathfinding - do not use last visited node

I want to achieve, that the last moved to node is not taken in consideration on the next created path.

Once a node has been reached i recreate the path. Move to next node and so on.

The problem is, the goal node is moving, so it can happen the enemy creates a path backwards, which i want to avoid.

The enemy should always take the optimal way but never backwards/where he came from. How is that possble?

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
0

Answer by Bunny83 · Apr 26, 2018 at 10:08 PM

The enemy should always take the optimal way but never backwards

Well those two conditions may collide. If there's a way right around an obstacle or left around A* will always find the shortest path. If the shortest path is the left way it will go left. However if you re-calculate the path when the target has moved more to the right it's possible that the right way is shorter. Just excluding the last node will not help with this problem. Even when you exclude the last node the right path might still be shorter, just with an extra side step.


One solution is to simply avoid recalculating the path each step if the path is still relatively long. So for example calculate a path to the target. If it's 20 nodes long you may recalculate the path once you moved 20%, 30% or 40% of the path. That means after about 4-8 blocks it recalculates a new path.Now the new path might be only 15 nodes long. That means as closer the enemy gets the more often it recalculates the path. This should eliminate such edge cases i've mentioned above. Of course if you want an instant reaction when a previously walkable path gets blocked, you can still trace the path each step to check if all nodes are still valid. If the path gets blocked just do an immediate recalc.


Such an approach is also greate to minimize recalculation overhead. Especially when an enemy is far away A* can get quite expensive in some edge cases.

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 OctoMan · Apr 27, 2018 at 06:12 PM 0
Share

Hi Bunny,

thanks alot for that indepth info. Since i only check 4 dirs i excluded the search for the diagionals. Somehow i just can't exclude the "back" direction, it always seem to stop after 1 step and can't find another optimal way after that step.

I also tried to create the optimal path and somehow store an alternate pass, with excluding the last node. But it doesn't work properly, because it may end in a "deadend". But was close to what i thought of.

The % approach is an interesting idea, but still can end up in a situation the enemy turns backwards and moves to the last visited node.

I already notice excluding the last node directly doesn't work properly as well.

Somehow i think to store the "best path" and override it with a maybe not so optimal but excluded back node anyhow is the way it could work. Do you have an idea to such approach?

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

138 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

Related Questions

[Arongranberg A * Pathfinding Project] How to move units without overlaping of them? 1 Answer

Is it possible to have a navmesh agent that ignores obstacles? 1 Answer

Which NavMeshSurface is a point (already on the NavMesh) on? 0 Answers

A* Pathfinding Project with composite colliders. 2 Answers

Can i use A* pathfinding on planes? 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