CallOfCreator.PathfindingAPI
1.0.2
dotnet add package CallOfCreator.PathfindingAPI --version 1.0.2
NuGet\Install-Package CallOfCreator.PathfindingAPI -Version 1.0.2
<PackageReference Include="CallOfCreator.PathfindingAPI" Version="1.0.2" />
<PackageVersion Include="CallOfCreator.PathfindingAPI" Version="1.0.2" />
<PackageReference Include="CallOfCreator.PathfindingAPI" />
paket add CallOfCreator.PathfindingAPI --version 1.0.2
#r "nuget: CallOfCreator.PathfindingAPI, 1.0.2"
#:package CallOfCreator.PathfindingAPI@1.0.2
#addin nuget:?package=CallOfCreator.PathfindingAPI&version=1.0.2
#tool nuget:?package=CallOfCreator.PathfindingAPI&version=1.0.2
<p align="center"> <img src="github/logo.png" width="180" alt="Pathfinding API Logo"> </p>
Pathfinding API
An Among Us mod that adds pathfinding support for other mod developers to use.
Features
- Uses A* pathfinding to find routes through the map while checking for collisions
- Supports Airship moving platforms, ladders, Fungle ziplines, doors, decontamination doors, and vents
- Fully supports the Submerged map, including elevators, floors, and vents
Installation
- Download
PathfindingAPI.dllfrom the Releases tab. - Place it in
BepInEx/pluginsalongsideReactor.dll. Reactor is required. - Install a mod that uses the API. Pathfinding API does not create NPCs by itself.
All players in the lobby need both Pathfinding API and Reactor installed.
Usage
Add a reference to your project
Reference PathfindingAPI.dll directly or add it as a project reference.
Alternatively, reference the NuGet package.
Then add the following dependency to your main plugin class:
[BepInDependency(PathfindingPlugin.Id)]
Move a player
using PathfindingAPI.Core;
using PathfindingAPI.Movement;
using PathfindingAPI.Navigation;
using PathfindingAPI.Options;
using Reactor.Utilities;
using UnityEngine;
Coroutines.Start(PlayerControl.LocalPlayer.CoMoveTo(
new Vector2(x, y),
result =>
{
if (result.Status == PathMovementStatus.Arrived)
DoSmtArrived();
else
DoSmt(result);
},
options: new PathOptions { AutoOpenDoors = true }));
Replace DoSmtArrived and DoSmt with your own handlers.
The callback runs when movement either finishes or fails. The result includes the movement status, planned path, and the waypoint where movement stopped.
Call this on the client that owns the player. If you want to move another player's character, send the request to that player's client first. Movement itself will synchronize normally.
PathOptions controls which types of routes the pathfinder is allowed to use:
| Option | What it does |
|---|---|
UseLadders |
Allows routes that use ladders. |
UseZiplines |
Allows routes that use Fungle ziplines. |
UseDecontamination |
Allows routes through decontamination doors and waits for their normal cycle. |
UseMovingPlatforms |
Allows routes that use the Airship moving platform. |
UseElevators |
Allows routes that use Submerged elevators. Has no effect on other maps. |
WaitForDoors |
Allows routes through closed doors and waits for them to open. When disabled, closed doors are avoided unless AutoOpenDoors is enabled. |
UseVents |
Allows routes through connected vents when the player's role is allowed to vent. |
AutoOpenDoors |
Requests that a closed door opens when the player reaches it. |
Ladders, ziplines, decontamination, moving platforms, and elevators are enabled by default.
WaitForDoors, AutoOpenDoors, and UseVents are disabled in a new PathOptions instance.
When no options are provided for a player-based search, vent usage follows that player's normal vent permissions.
The API can also find routes for NPCs, but it does not create or manage custom NPCs for you. Vent traversal is only available if the player's current role allows them to vent.
For grid spacing, wall costs, and other pathfinding settings, see PathOptions.cs.
Movement tolerance is in PathMovementSettings.cs. Pass these settings to CoMoveTo or FollowPath when you need to change them.
Find a route without moving
Create a request using two Vector2 positions. start is the starting position and goal is the destination.
var request = MapPathfinding.CreateRequest(start, goal);
Call request.Step() once per frame until request.Status is no longer PathStatus.Searching.
After that, read request.Result. Only use the returned points if the result status is PathStatus.Found.
To cancel an unfinished search, call:
request.Cancel();
Do not set PathStatus.Cancelled manually.
You can also yield request.Run() from a coroutine to let the search run over multiple frames.
If you prefer using a callback:
Coroutines.Start(MapPathfinding.FindPath(start, goal, path =>
{
if (path.Status == PathStatus.Found)
ShowRoute(path.Points);
}));
Replace ShowRoute with your own handler
Follow a route you already planned
Coroutines.Start(player.FollowPath(
path,
result => OnMovementEnded(result)));
The player should start near the route's first waypoint
FollowPath follows the route you provide, while CoMoveTo first calculates a route from the player's current position.
Movement stops if the player becomes blocked or cannot use one of the required crossings.
Your callback can start another pathfinding request if needed. For example, you could retry with UseMovingPlatforms = false if the Airship moving platform cannot be used.
Submerged
The Pathfinding API now supports the Submerged map and detects Submerged automatically.
MapPathfinding.IsSubmergedLoaded() checks whether the Submerged plugin is loaded, while MapPathfinding.IsSubmergedMap() checks whether the current map is Submerged (MapId = 6).
Elevator routes can be used like this AutoOpenDoors does not affect elevator usage.
Coroutines.Start(player.CoMoveTo(
destination,
result => OnMovementEnded(result),
options: new PathOptions { UseElevators = true }));
Set UseElevators = false to avoid using elevators
Cross-floor vents can still be used when UseVents is enabled and the player's role allows venting.
Elevators appear in path.Crossings as PathTraversal.Elevator. If you are using a custom movement controller, it must handle this crossing explicitly. Do not move directly between the two elevator waypoints
Results
| Movement status | Meaning |
|---|---|
Arrived |
The player reached the final waypoint. |
NoPath |
Pathfinding failed. Check the path's search status for more information. |
Cancelled |
The supplied pathfinding request was cancelled. |
Interrupted |
Movement was interrupted because the player died or disconnected, a meeting started, or the game ended. |
NotOwner |
This client does not own the player |
Busy |
The player cannot move or already has an active path follower. |
Blocked |
The player stopped moving or failed to make progress. |
TraversalFailed |
A transport, crossing, or doorway could not be used. |
InvalidPath |
The supplied path contains invalid waypoint or crossing data. |
Credits
- Nebula - Inspiration for the pathfinding API
- WanderingPix - Project icon
- Reactor - Main dependency used by the mod
Disclaimer
This mod is not affiliated with Among Us or Innersloth LLC, and the content contained within it is not endorsed or sponsored by Innersloth LLC. Portions of the materials contained herein are the property of Innersloth LLC.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- BepInEx.Unity.IL2CPP (>= 6.0.0-be.735)
- Reactor (>= 2.5.1-ci.384)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.