Hey guys, I’m very new at this so please go easy on me. I just started playing around with A* pathfinding in Unity and I find it very interesting, but I’m stuck on something.
Let me first explain what my goal is so that you understand what I’m trying to do. Right now I’m simply trying to make a tile based game with grid movement for both the player and ai controlled characters.
Both the player and ai characters use A* pathfinding to move around. How do I make a tile inaccessable by anyone if there’s already a character occupying it so that the pathfinding won’t use that tile for anyone to find a path?
I’ve tried placing all characters under a layer which I then checked for collision detection and then rescan the graph in realtime, but that seems to interfer with the pathfinding for the character occupying the tile.
Sorry for my extreme noobyness, I hope I didn’t make anyone cringe too much… Thanks in advance
I just realised I pretty much exactly have the same problem as this guy in this thread:
but the last part isn’t solved. Using penalties, characters can still move through eachother if they absolutely have to. Any ideas?
I pretty much figured out a way to do it. I’m setting a penalty on nodes characters currently stand on, and I also loop through each node in a path and make sure none of them have said penalty. It’s working exactly the way I want and expected it to but please feel free to tell me if there’s a better and more efficient way to do it, I’m still all ears.