[RELEASED] SAP2D System 1.1 (FREE Astar Pathfinding for 2D games)

The SAP2D (Simple A * Pathfinding 2D) path search system is based on Astar algorithm – the shortest path between two points. This search system path you can use to write your own artificial intelligence systems that will help you implement enemies or a system of controlling a character in your 2D game.

The system is very simple, so if you are not an advanced Unity user, you can easily and fast set up the SAP2D system.

Also SAP2D System can be used in a 3d games. For example a GPS Navigation in your car like in a gta:

SAP2D Features:

  • 2D Physics support
  • Manual Obstacles Editing
  • Dynamic Obstacles support
  • Built-in AI

Assets Store Page
Online Documentation

1 Like

Dynamic obstacles in SAP2D works not pretty nice, because the latest SAP2D build was in a Unity 5.2.5, composite colliders 2D was included in 5.6 version. But, you can fix it. To put simply you can add dynamic obstacle component in a base object wih composite collider component and add dynamic obstacle component in a children objects, also change them colliders to composite collider in a Coll 2D field in Dynamic obstacle script.

This procces will fixed in the next SAP2D version.

@MiSchneider In this system, is there a way to set waypoints in a larger map via clicking?

Can you describe your question more detail? In this version the path calculates as a array of vectors. You can write your own script with placing waypoints by cliking and call FindPath method to calculate path to them (as movement in Dota 2). Did I understand you correctly?

Hi, this project is alive? thanks

Of Course, I really work hard to release new version. Soon I post some spoilers about it, I hope… -_-

1 Like

SAP2D 2019.1b allows you to comfortably work with large pathfinding grids due to draw optimizations solutions. It means that SAP2D pathfinding system can be used in games like a Rimworld and etc, where your agents uses big map to find path. I think that awesome!

For example I have 1000x1000 grid (1 million tiles)

4207564--373333--Honeycam 2019-02-12 19-15-14.gifWhat do you think of this bug?
The purple square is a dynamic obstacle.
The player has rigid body 2D, one call rider and code.

It happened, because of dynamic obstacle calculation. The player moves very fast and dynamic obstacle doesn’t calculate collisions in time. Try to add any tag to the player and also add this tag to Ignore Collision Tags list in the SAP2D Manager. It will help you.

1 Like

oh. Thanks. I solved it.

I really like your path finding system! I have one question though. How would I make AI jump over obstacles? If you could help it would be greatly appreciated!

Thanks. So… It’s very difficult to calculate how AI will jump according with finded path. It is possible if your obstacles have fixed height. Maybe anybody will find a solution to calculate height of each obstcale and change the jump angle in realtime. I think that creating of jumping AI is unpossible with dynamic obstacles. I wrote some code to try to create jumping AI. I’m sure there is a more performant solution.

https://www.youtube.com/watch?v=-6nvs1TrhOI

You can write me your email if you want this project with my solution.

[04.15.2019] SAP2D 2019.1.2b Update:

  • Added multigrid support.

  • Added big grids drawing optimisations.

  • Added new tool for manual obstacles editing mode.

  • Added API optimizations.

  • Added SAP2D About window.

  • Optimized pathfinding core.

  • Ignore Obstacles list changed to Obstacles Layer parameter.

  • Ignore Coners parameter changed to Cut Coners parameter.

  • Updated SAP2D Manager script.

  • Updated SAP2D Dynamic Obstacle script.

  • Updated Documentation.

  • Updated manual obstacles editing panel. Unwalkable tiles which placed by user saves in single scriptable object on User Data folder.

I have another question. Can I use the Super Tile Map Asset with this? I think you asset is the best path finder 2D but I want to use with Super Tile Map Editor. Thanks!

I think its possible. Super Tile Map Editor uses square tiles too and you can create new grid in SAP2D Manager and set tile size according with tile size in the Super Tile Map Editor. Its very inportant to find correct path. But of course you can do this in 2D space only.

1 Like

Is the new version of “rubber” not working properly?
The information in “UserGridData” cannot save “rubber”.

Oh… I understood the problem. I fix some code in UserGridData script. Now it works right. Thanks


using System.Collections.Generic;
using UnityEngine;

namespace SAP2D {

    public class SAP_UserData : ScriptableObject
    {
        [HideInInspector]
        public List<SAP_TileData> UnwalkableTiles = new List<SAP_TileData>();

        public void AddData(SAP_TileData tile)
        {
            for (int i = 0; i < UnwalkableTiles.Count; i++)
            {
                if (UnwalkableTiles[i].x == tile.x && UnwalkableTiles[i].y == tile.y) return;
            }
            UnwalkableTiles.Add(tile);
        }

        public void DeleteData(SAP_TileData tile)
        {
            for(int i = 0; i < UnwalkableTiles.Count; i++)
            {
                if(UnwalkableTiles[i].x == tile.x && UnwalkableTiles[i].y == tile.y)
                {
                    UnwalkableTiles.RemoveAt(i);
                    break;
                }
            }
        }
    }
}

thanks for your help!
A new problem occurred after adding two “grid”.
Can’t edit pathfinding.

What do you mean?

A new problem occurred after adding two “grid”.
I can’t edit the pathfinding grid and store multiple “grid” messages.