- Home /
2D A* pathfinding in free version?
Hi, I'm making a 2D RPG game where the character will be walking around different small towns. Each town will be a separate level so it won't be a seamless world. Anyways, I wanted to make his movements be where the player clicks and the player goes there (similar to in RuneScape) I was wondering if there's a simple way to do path-finding in a 2D game, with the free version of unity.
It would be very simple movements, just vertical and horizontal (no diagonals) and preferably on a grid.
I've been looking online and into things like A* and while I can kind of grasp the principles of A* i wouldn't even know how to begin translating that into code. Does anyone have an example code they could show me or a tutorial they could link me to that would explain how I go about making a code for the A* algorithm? Or if you know a simpler way I could do this, that would help too!
As a side-note, I've been thinking about getting the pro version, so if anyone knows what extra 2D-relevant tools come in it I would be interested in knowing that. I've also heard the pro version comes with built-in pathfinding. Is this true and to what extent?
Thanks!
You don't have to write your own A* pathfinding script, you can use free version of A* Pathfinding project( http://arongranberg.com/astar/ ). I have been using it for a top down game and it works really well. What you want to do is not impossible at all with A* Pathfinding project. It has some basic scripts already in it that you can use (like Seeker and AIPath) that will make a character move towards the point you have assigned, so you don't really have to worry about the pathfinding part that much. So if you do use A* pathfinding project all you would have to do is figure out how to make it so that the place you are clicking on would become your characters next target and then assign that to the "target" in AIPath script.
Not sure if this will be any use to you, but when I was doing pathfinding for my project I found this useful http://qiao.github.io/PathFinding.js/visual/ It let me play around with how the algorithms worked and how they searched through nodes
Answer by darthtelle · Jul 07, 2014 at 10:10 AM
I used this website to write the A* algorithm in my project. It's very helpful in talking through the principles and the code. Also, Wikipedia has a good pseudo-code section.
Edit: Hmm.. Unity doesn't like that Wiki link!! http://en.wikipedia.org/wiki/A*_search_algorithm#Pseudocode
Your answer
Follow this Question
Related Questions
Unity 3.5: What is the definition of PLE algorithm? 1 Answer
A* optimization and path help 0 Answers
Preventing lines from overlapping 1 Answer
Help with A* algorithm 0 Answers
A* Implementation broken? 0 Answers