Tag Info

New answers tagged

14

I haven't looked at specific implementation of A* by Aaron but with a normal A* you could include the 'block tower' as passable terrain but update the heuristic so that the 'cost' is much higher than a normal tile (so that AI will evaluate whether it is easier to destroy the block and continue or simple go around via the path that is not blocked). Then you ...


0

If what you are looking for is a sort of taunting tower you can add a collider to it set as is trigger and when the minions enter the trigger they are just scripted to attack the tower. If you want the minions to attack the towers only when there aren't alternative paths, then when the path is blocked and the A* is called to calculate another path if it ...


0

To make it easier for you to switch between world coordinates and grid coordinates, you should make two functions, projectToWorld and projectToGrid. pseudo code: /** * returns the topleft position of a given grid coordinate. */ function projectToWorld(gridX, gridY) { return new Vector2(TILE_WIDTH * gridY, TILE_HEIGHT * gridY); } /** * ...


2

For the A-star algorithm you must provide a data structure that, for vey legal current position of the agent, provides the set of possible moves from that location along with the cost of making that location change. The most common means of providing such a data structure, especially for a rectangular grid, is a 2D array of lists. However for more complex ...


2

Your algorithm only looks at the diagonals: final int[] axs = new int[] { -1, 1 }; final int[] ays = new int[] { -1, 1 }; ... for(final int ax : axs) { for(final int ay : ays) { final int x = current.x + ax; final int y = current.y + ay; You need to also check the orthogonal tiles: (x+0, y+1), (x+1, y+0), (x+0, y-1), (x-1, y+0). In ...


0

Pick a random point on the map which is not blocked. Then Calculate a path from the current position to the destination using a stock route finding algorithm like Dijkstra's Algorithm or A*. When no route can be found, then the random destination is either unreachable. Pick another point in that case. To avoid a deadlock in case there is no possible move ...


1

You may be interested in Nodal Pathfinding. The concept is similar to placing waypoints, except you generate these way points on top of your world. The waypoints are then used with an A* pathfinder, to determine the optimal path. Have a look at the blog here: http://www.jgallant.com/nodal-pathfinding-in-unity-2d-with-a-in-non-grid-based-games/ Another ...


1

Use waypoints in your map. The enemy AI in "patrol" state chose a random visible waypoint as target. Reached the waypoint repeat step 1. (eventualy excluding current waypoint) If you don't want to place manualy waypoints you can generate them at the corners via script : here follow an example: cons: the enemy will patrol in straight lines from ...


0

Well if you don't want to use A* for some reason, try "Dijkstra’s algorithm" or "Greedy best first search".


7

A* would work fine for this task, but since your map is small, Breadth First Search would work too, and it's even simpler than A*. These are “graph search” algorithms, which require you to tell them what the allowed moves are. They are not limited to grids. In your case you would tell it that the allowed moves from (x,y) are to (x+1,y-1), (x+1,y), and ...


0

a* will work fine. In the selection of neighbor cells consider forward, forward_up, forward_down


1

A* will certainly work for this. Linked below is an excellent tutorial on how to implement it. 1) Add the starting square (or node) to the open list. 2) Repeat the following: a) Look for the lowest F cost square on the open list. We refer to this as the current square. b) Switch it to the closed list. c) For each of the 8 squares adjacent to this ...


0

The easiest solution is to use any flood-type algorithm, for example as you mentioned Dijkstra's algorithm. The only difference is the stopping condition: if(Resources.Any(r => r == node)) { ...} instead of if(resource == node) { ...} you can improve its performance by excluding resources that cannot be possibly reached yet from the check (=found ...


1

here you go, here is a implantation of the A* in Action script 3, i wrote this a few years ago, there are a few things such as grid, grid view and node classes that i'm using which really don't have anything to do with the A* algorithm itself, and are all used for the graphic and visual side of the work, still if you are interested i can put them here so you ...


1

modify a* considering goal as a set of points instead of a single point. If the euristic function is the distance, the each step of a* chose the path that minimize the closest point distance. Check also this


0

You could check to which tile the player is closer to and then just set the position of the player to the centre of the tile.


1

You could do this by teleporting the player around - in the case of a staircase, after reaching a certain point just reposition the player several steps back. Of course, the environment would have to be crafted in a way so that the player doesn't notice it (that is, when he looks around in both locations (place where the teleport is and the place he gets ...



Top 50 recent answers are included