{"id":19564309,"url":"https://github.com/ronenness/unity-2d-pathfinding","last_synced_at":"2025-04-27T00:32:56.414Z","repository":{"id":39006660,"uuid":"58169948","full_name":"RonenNess/Unity-2d-pathfinding","owner":"RonenNess","description":"A very simple 2d tile-based pathfinding for unity, with penalty supported","archived":false,"fork":false,"pushed_at":"2017-09-16T12:00:02.000Z","size":5,"stargazers_count":146,"open_issues_count":0,"forks_count":16,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-04T19:08:05.754Z","etag":null,"topics":["2d-tile","pathfinder","pathfinding","unity","unity-2d-pathfinding"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RonenNess.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-06T00:53:08.000Z","updated_at":"2025-03-30T06:12:15.000Z","dependencies_parsed_at":"2022-09-12T20:23:22.379Z","dependency_job_id":null,"html_url":"https://github.com/RonenNess/Unity-2d-pathfinding","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RonenNess%2FUnity-2d-pathfinding","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RonenNess%2FUnity-2d-pathfinding/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RonenNess%2FUnity-2d-pathfinding/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RonenNess%2FUnity-2d-pathfinding/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RonenNess","download_url":"https://codeload.github.com/RonenNess/Unity-2d-pathfinding/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251073488,"owners_count":21532005,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["2d-tile","pathfinder","pathfinding","unity","unity-2d-pathfinding"],"created_at":"2024-11-11T05:21:22.403Z","updated_at":"2025-04-27T00:32:56.161Z","avatar_url":"https://github.com/RonenNess.png","language":"C#","readme":"# Unity-2d-pathfinding\nA very simple 2d tile-based pathfinding for unity, with tiles price supported.\n\n## NEW REPO\n\nI moved this script to a dedicated repo for Unity utilities.\n\nA newer version can be found [here](https://github.com/RonenNess/UnityUtils/tree/master/Controls/PathFinding/2dTileBasedPathFinding) along with other useful Unity scripts.\n\nThis repo will remain online but won't be maintained.\n\n## About\n\nThis code is mostly based on the code from [this tutorial](https://www.youtube.com/watch?v=mZfyt03LDH4), with the following modifications:\n\n- Removed all rendering and debug components.\n- Converted it into a script-only solution, that relay on grid input via code.\n- Separated into files, some docs.\n- A more simple straight-forward API.\n- Added support in tiles price, eg tiles that cost more to walk on.\n\nBut overall most of the credit belongs to [Sebastian Lague](https://www.youtube.com/channel/UCmtyQOKKmrMVaKuRXz02jbQ), so show him your love.\n\n## How to use\n\nFirst, copy the folder 'PathFinding' to anywhere you want your asset scripts folder. Once you have it use pathfinding like this:\n\n```C#\n// create the tiles map\nfloat[,] tilesmap = new float[width, height];\n// set values here....\n// every float in the array represent the cost of passing the tile at that position.\n// use 0.0f for blocking tiles.\n\n// create a grid\nPathFind.Grid grid = new PathFind.Grid(width, height, tilesmap);\n\n// create source and target points\nPathFind.Point _from = new PathFind.Point(1, 1);\nPathFind.Point _to = new PathFind.Point(10, 10);\n\n// get path\n// path will either be a list of Points (x, y), or an empty list if no path is found.\nList\u003cPathFind.Point\u003e path = PathFind.Pathfinding.FindPath(grid, _from, _to);\n```\n\nIf you don't care about price of tiles (eg tiles can only be walkable or blocking), you can also pass a 2d array of *booleans* when creating the grid:\n```C#\n// create the tiles map\nbool[,] tilesmap = new bool[width, height];\n// set values here....\n// true = walkable, false = blocking\n\n// create a grid\nPathFind.Grid grid = new PathFind.Grid(width, height, tilesmap);\n\n// rest is the same..\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fronenness%2Funity-2d-pathfinding","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fronenness%2Funity-2d-pathfinding","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fronenness%2Funity-2d-pathfinding/lists"}