Pathfinding on moving object question

Hi,

I am thinking of buying the A* pathfinding asset because i am unable to have a navigation path on a moving object (A ship) using the normal unity navmeshagent. My question thus is : Does A* support pathfinding on a moving object?

Thx in advance,

Niels

Hi

Yes, to some extent. It is not that well documented and there are some limitations for it, however there are supports scripts to be able to use a recast graph with agents on a moving ship. In the pro version there is an example scene called ‘Moving’ which showcases this.
You can see a small preview of this in the showcase video for the package. Here is a link to the specific time in the video where it is shown: https://youtu.be/hmx1sx6ezQA?t=81

Hi,

Thankyou for your fast answer. It looks pretty nice indeed.
Before i buy the asset tho i have a couple of more questions:

  • For a ship with alot of obstacles that can change position. Is this bad performance wise?
  • What are the limitations you are talking off?
  • Is there a big performance difference between a moving ship (and thus a moving path)?
  • I see the latest update on the asset is almost 6 months ago. At first i though the asset wasnt really getting updated anymore but than i saw this insanely active forum. Are you thinking of using the new unity job system or other future updates/compatibilities?
  • When using the navmeshagent to walk to a nonwalkble object it finds the ‘closest’ place that it can walk to to reach it. However sometimes this is a floor under the object he has to walk to. Does this happen in your tool aswell?

A screenshot of the scene/ship i am talking about:

Thx again for your help

Hi

So the way pathfinding on a moving ship is implemented is that the graph is scanned when the ship is at the world origin. Then once the ship is moved to some other place in the world, the movement script keeps track of the ship’s position and orientation so that when it requests a path, or follows a path, it can translate between the world coordinates and the graph coordinates easily. As only the movement script keeps track of this however, and the graph doesn’t actually move, there are some limitations. Graph updates, for example, don’t work properly on the moving ship. Since the graph is actually still at the world origin, the obstacles will be at the wrong positions if they are on the moving ship. You can solve this however by keeping a copy of the ship at the world origin which you update in the same way as the moving ship. That will allow you to get working obstacles.

There is no big performance difference. It is essentially just one or two extra matrix multiplications per frame.

I release a lot of beta versions. There have been 10 beta versions released since 4.1.16 (it’s now at 4.1.26). You can find the beta versions here: https://www.arongranberg.com/astar/download. I am soon-ish going to release a new non-beta version.
I am considering the unity job system. It seems very useful for some parts of the system. Especially the burst compiler. It’s always tricky adding new Unity features though as the package has to stay compatible with older versions of Unity too (this package is compatible with all versions of Unity back to Unity 5.2.2). But they certainly look interesting.

Yes, my package will also try to find the closest point it can reach to the destination. If you have more information you could write a custom NNConstraint (nearest-node-constraint) which the path uses. You could use this to for example exclude picking a node on another floor (though you probably want a fallback in case there are no reachable nodes on the same floor).