New answers tagged

0

I don't known if you've solved the issue since the question was posted, but how do you expect to know which is the carrier that is closer to the building at a given time, if you don't know their shortest path? It does not make sense. You need to calculate some sort of path-finding between building and carriers. And just after that, select the closest ...


2

Instead of pathing from each new enemy to the player as they spawn of the player moves significantly. Do a floodfill from the player to fill the entire map with how far the player is from each tile and which way he is. Then for pathing you just follow the arrows. The floodfill Will only need to update the neighbours of the tiles whose value changed after ...


0

You probably run the pathfinding algorithm every frame. It should only happen once, when the enemy spawns. If your area is destroyable, then you will need to do it every time an obstacle is destroyed.


3

If I am not mistaken these types of problems are usually solved by backtracking family of algorithms. I would use an algorithm similar to DFS: recursively search the solutions tree and whenever leaf node is reached, save the path if it was the longest discovered. After reaching leaf node, backtrack to last "crossroads" and take the other turn(s). In order to ...


3

Edit: I initially assumed both moving and attacking only happened N/S/E/W, and that your problem was other monsters were failing to approach the pile-up at all. Now I understand that your attacking range is larger than your movement step, so enemies should prefer navigating to a tile diagonally-adjacent to the player over waiting behind an attacking monster ...


0

You didn't provide a lot of information about how your pathfinding currently works, so I'm going to assume what Nils has assumed, which is that your bats are seeking a path to the player, not to the places adjacent to the player. My solution to this would be: - Find every spot next to the player. - For every one of those spots, find a path to it. - If no ...


1

I think your issue is that you pathfind towards the players tile rather than to a tile that he can be attacked from. Since there is no actual path to the player in that case, since diagonal movement isn't allowed, of course they can't find a path. If you just want them to get closer you can put a maximum on the number of tried nodes and always move towards ...


1

"Entrances" are simply the rectangles where both clusters have open squares on their side, right? Computing them in pseudocode is something like this: Iterate along edges shared by two clusters For each tile, if tile is open Check if tile on the other side of the edge is open. If so, If currently tracking an entrance, add these two tiles to it. ...


0

There are many ways you can do it. A* and such is a good option, but lacks in documentation. You could do something like place nodes quasi-randomly around the map and check which nodes can see each other and build a little web of nodes. Not the most optimal but easy to understand.


2

There is nothing wrong with your algorithm, it finds the shortest path. Want you want you can do with a extra step after your path is found. Usually its called something like 'SmoothPath' first compress the path: you're only interested in the important points, the important ones are the ones where the direction changes: in this example the startPoint, the ...


0

If you have a list of all available teleports per map containing information about their position and what map they link to, you could find out in a first step which teleport will bring you the closest to your target and then do a local A*-search to that chosen teleport.


0

This answer sort of tries to solve the question in a different way than you ask, but is useful in the context of games development, especially since your code appears to be working and finding a short path. Is there any place you store X & Y coordinates in nodes ? because you could apply interpolation by using a catmull rom spline by taking all the ...


0

Found the issue with my program, the algorithm was mostly right, I just had to modify my if statements when taking things on and off the closelist to include the the if statement whether it was smaller than the previous route, since we only want to take things off the close list if a better route has been found. A secondary issue popped up when I realized I ...


8

I don't know which technique was specifically used in Cossacks, but I guess you are also interested in the problem at hand in general terms. In fact, nowadays, there are ways trough which such result can be achieved - although of course advanced techniques are needed in demanding scenarios. Overall, two are the main bottlenecks when implementing ...



Top 50 recent answers are included