16
2014
2D A* Pathfinding (wip 4)
Didn’t find any simple 2D A* for Unity, so started converting/modifying this
(Fast A-Star (2D) Implementation for C# by Christoph Husse) into Unity to use with sprites on a 2D level/map..
Current progress:
– Basic A* grid works (using texture/pixels grid)
– Automatically generate walkable grid area map using raycasts or predefined mask texture
– Make it work with sprites (as movement waypoints/path)
– Needs automatic wall offset (keep distance from walls) : added for raycast version
– Recalculate grid on mouseclick (sets target position)
– Invidual AI bot movement (can set targets per bot)
– AI bot stuck flag (when gets stuck, set bool value)
– Mecanim animations for AI bot
– Invidual Agent controllers
– AI bot reachedTarget bool flag
TODO:
– Option to disable diagonals (especially in low resolution grids)
– Needs automatic wall offset (keep distance from walls) : for texture mask version?
– Diagonal movement is faster than straight?
– Dynamic obstacles (recalculate path if dynamic collider at front? and doors? or just stop moving if enter door trigger area..)
– Chase player + Run away from player
– Path smoothing & smoother movement
– Path optimization? (grid causes jagged movement (going from cell center to another cell center)
– AI Agent flocking or collision avoidance (to that they wont all stack together..)
– AI bot should give up trying to reach target if stuck for a certain time?
– Problem: rigidbody2D.MovePosition() gets sometimes stuck on walls/objects..
—
Webplayer:
http://unitycoder.com/upload/demos/2DAStarPathFinding/ (V1)
http://unitycoder.com/upload/demos/2DAStarPathFinding2/ (V2)
http://unitycoder.com/upload/demos/2DAStarPathFinding3/ (v3)
http://unitycoder.com/upload/demos/2DAStarPathFinding4/ (v4)
—
Image#2: Using custom obstacle texture
—
Image#3: Raycast scanned obstacle map (with adjustable wall avoid radius, thats why some cells are marked red near walls)
—
Image#4: Sprite following the path (see webplayer v2)
Related Posts
10 Comments + Add Comment
Leave a comment
Recent posts
- MotionVector Effect: Object “disappears” when paused
- [GreaseMonkey] Unity Forum Fixer
- UnityHub: Make Hub application background Translucent
- Customize SpriteShapeRenderer quality (but has issues)
- Editor tool: Copy selected gameobject’s names into clipboard as rows (for Excel)
- Editor tool: Replace string in selected gameobject’s names
- UnityHub: Enable built-in Login Dialog (no more browser login/logout issues!)
- Use TikTok-TTS in Unity (with WebRequest)
- Create Scene Thumbnail Image using OnSceneSaved & OnPreviewGUI
- webgl+javascript TTS
- Using Moonsharp (LUA) + Unity Webgl
- Using 3D gameobject prefabs with Unity Tilemap + NavMesh Surface
Recent Comments
- [Asset Store] Point Cloud Viewer & Tools on
- [Asset Store] Point Cloud Viewer & Tools on
- Vector3 maths for dummies! on
- UnityHub: Make Hub application background Translucent on
- UnityHub: Make Hub application background Translucent on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- [Asset Store] Point Cloud Viewer & Tools on
I’ve just created a Unity demo project featuring my old A* implementation and uploaded in to Bitbucket.
https://bitbucket.org/alexzzzz/astar-demo
It runs 5 times faster in average than Christoph Husse’s implementation.
nice, will check it out soon! (need this for a small prototype game..robots patrolling, chasing player)
nice looking collision avoidance system demos (see videos)
http://gamma.cs.unc.edu/CA/
simple obstacle avoidance:
http://thewaterbear.com/obstacle-avoidance-a-i/
somekind of A* pathfinder? :
https://gist.github.com/rakkarage/c0b304dfd8023f672870
forum image:
http://forum.unity3d.com/threads/a-better-way-of-drawing-a-grid-in-editor.283752/#post-1873572
intro to A* pathfinding:
http://www.raywenderlich.com/4946/introduction-to-a-pathfinding
BFGames: Simply A* Pathfinding! NOW FREE (not sure if could work with sprite 2D view?)
http://forum.unity3d.com/threads/released-bfgames-simply-a-pathfinding-now-free.164003/
Crowd Movement on 2D Grid
http://rayofcode.wordpress.com/2015/01/04/crowd-movement-on-2d-grid/
simple A* pathfinding C#
https://gist.github.com/stylophone/3448727
2D Pathfinding (unity)
https://github.com/SebLague/Pathfinding