#How to move circular around one object in unity?

1 messages · Page 1 of 1 (latest)

brittle frigate
#

Suppose the Red object is the enemy and Yellow is its target. There is a mountain in between them. Then how can I move around the object? Suppose 4 mountains are forming a wall, then how can I move around all four of them?

scenic hound
#

You'll want to look into pathfinding algorithms for that.
Unity already has a built-in pathfinding system that uses the A* algorithm and is sufficient for most use cases.
But you could also implement your own solution using either a custom implementation of A* or another algorithm, such as Dijkstra's Algorithm or Octrees.

scenic hound
#

Also I feel like the question is a little misleading; once you have "[multiple] mountains forming a wall" the "circular" part wouldn't apply anymore, after all.

hybrid bronze
scenic hound
#

No.
Dijkstra's algorithm for example uses nodes iirc (as in, you define points and connections between them, give each connection a weight and the algorithm figures out the best path between two nodes based on that).
A* can use a grid, but Unity's NavMesh for example uses it (according to the documentation) with a navigation mesh, rather than a grid.
And Octrees are basically a volumetric nav mesh made out of non-uniform boxes.

hybrid bronze
#

Sounds complicated without a grid-system.. but that's likely because I haven't read anything about nodes😆 Having a grid-system makes good sense because there you can define if the current grid is occupied, walkable etc. Though I suppose a node-system is not that much different..?

#

Just a lot to grasp really, so many questions like : what if there's something in the way"

scenic hound
#

With a node system, you kinda simplify it even more. Rather than determining what is walkable and what is not, you just define paths that can be taken and combine multiple of those to get you to your destination.
Gonna go out on a limb here and assume that that's probably what satnavs do.

hybrid bronze
#

Does that mean nodes are faster? or more performant?

scenic hound
hybrid bronze
scenic hound
# hybrid bronze Does that mean nodes are faster? or more performant?

I haven't benchmarked it, but I would think that it's both a question of the exact implementation of pathfinding algorithm you use, as well as the scale of the space you want to navigate.
Generally speaking though, I would indeed assume that node-based approaches are faster (though likely less suited for game environments).

#

For reference: This StackOverflow reply outlines how (some) map applications optimize their path finding.
My earlier assumption about them using (a form of) Dijkstra's algorithm seems to have been not unfounded LUL

hybrid bronze
#

Interesting modification of Dijkstras' algorithm, though you mentioned it being less suited for game environments? what is recommended for game environments?

scenic hound
#

From what I know, the most common approach in game design is to use nav meshes.
They give more detailed information about the environment than a standard grid. And they still allow the use of A*, which at this point has been tried and tested a lot.

Of course, for use cases that deal with 3-dimensional navigation (as opposed to 2D where agents stay attached to a surface - usually the ground), things become more complex.
That's where structures like Octrees can replace NavMeshes (Warframe for example uses this in its space levels).

Nodes on the other hand don't adapt very well to game environments, because automatically placing them may prove difficult, distributing them manually would be tedious, and if you don't place a huge amount, any paths you get will be rather predictable and offer little (or no) variation.

hybrid bronze
scenic hound
#

There's a talk by the Warframe devs on YouTube where they describe their approach in detail.
It's a little difficult to find and I don't have access to my bookmark rn, perhaps I'll link it later.

hybrid bronze
#

Would be great tbh

scenic hound
#

Oh, and if you're working in a 3d space, you can also look up the Optimal Reciprocal Collision Avoidance (ORCA) algorithm. Iirc Warframe also uses that one in addition to their path finding, to prevent collisions between agents.

hybrid bronze