Skip to main content

Hybrid

A Types.Pathfinder that composes a Graph for the level and a local pathfinder for the geometry, the way the design plan lays it out. Name is "Hybrid".

With Prefer = "Graph" and RefineEnds = false the graph plans everything it can, and the local pathfinder (Roblox's navmesh, usually) only answers when the graph has no way there. Add a direct walker (Builder:UseDirect) and a target in plain view is walked at straight, so the navmesh is left for the odd place the graph does not reach. Blocked is the local pathfinder's Blocked when it has one, so a blocked local leg re-plans the whole route.

Functions​

new​

Hybrid.new(options: HybridOptions) → Pathfinder

Types

​

interface HybridOptions {
Graph: Pathfinder--

The long-range pathfinder, usually a Graph.

Local: Pathfinder--

The short-range one, usually a Navmesh or a Ladder of Straight and Navmesh.

LocalRadius: number?--

Studs within which the local pathfinder is tried first. Default 40.

RefineEnds: boolean?--

Plan the first and last legs locally. Default true.

Prefer: ("Local" | "Graph")?--

"Local": the local pathfinder first within LocalRadius, the graph beyond. "Graph": the graph for every route, and the local pathfinder only when the graph has no route (no node in reach, or no chain of links); LocalRadius is not used. Pair "Graph" with RefineEnds = false to keep the local pathfinder out of ordinary routes altogether: the graph's entry and exit nodes are chosen on a clear line (its LineOfSight option), so the end legs are walked straight. Default "Local".

}

Errors

TypeDescription
string`Graph` or `Local` missing.

FindPath​

Hybrid.FindPath(
self: HybridClass,
from: Vector3,
to: Vector3,
agent: Agent
) → (
string?--

Both pathfinders' reasons when neither found a way.

)

Close​

Hybrid.Close(
self: HybridClass,
step: Step,
seconds: number
) → ()

Passes the closure to the graph and the local pathfinder, whichever has Close.

Destroy​

Hybrid.Destroy(self: HybridClass) → ()

Destroys both pathfinders. Make one Local per agent; a Graph may be shared since its Destroy releases nothing.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "",
            "params": [
                {
                    "name": "options",
                    "desc": "",
                    "lua_type": "HybridOptions"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Pathfinder"
                }
            ],
            "function_type": "static",
            "errors": [
                {
                    "lua_type": "string",
                    "desc": "`Graph` or `Local` missing."
                }
            ],
            "source": {
                "line": 90,
                "path": "lib/Pathfinders/Hybrid.luau"
            }
        },
        {
            "name": "FindPath",
            "desc": "",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "HybridClass"
                },
                {
                    "name": "from",
                    "desc": "",
                    "lua_type": "Vector3"
                },
                {
                    "name": "to",
                    "desc": "",
                    "lua_type": "Vector3"
                },
                {
                    "name": "agent",
                    "desc": "",
                    "lua_type": "Agent"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Path?"
                },
                {
                    "desc": "Both pathfinders' reasons when neither found a way.",
                    "lua_type": "string?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 141,
                "path": "lib/Pathfinders/Hybrid.luau"
            }
        },
        {
            "name": "Close",
            "desc": "Passes the closure to the graph and the local pathfinder, whichever has `Close`.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "HybridClass"
                },
                {
                    "name": "step",
                    "desc": "",
                    "lua_type": "Step"
                },
                {
                    "name": "seconds",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 220,
                "path": "lib/Pathfinders/Hybrid.luau"
            }
        },
        {
            "name": "Destroy",
            "desc": "Destroys both pathfinders. Make one `Local` per agent; a [Graph] may be shared since its\n`Destroy` releases nothing.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "HybridClass"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 235,
                "path": "lib/Pathfinders/Hybrid.luau"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "HybridOptions",
            "desc": "",
            "fields": [
                {
                    "name": "Graph",
                    "lua_type": "Pathfinder",
                    "desc": "The long-range pathfinder, usually a [Graph]."
                },
                {
                    "name": "Local",
                    "lua_type": "Pathfinder",
                    "desc": "The short-range one, usually a [Navmesh] or a [Ladder] of Straight and Navmesh."
                },
                {
                    "name": "LocalRadius",
                    "lua_type": "number?",
                    "desc": "Studs within which the local pathfinder is tried first. Default `40`."
                },
                {
                    "name": "RefineEnds",
                    "lua_type": "boolean?",
                    "desc": "Plan the first and last legs locally. Default `true`."
                },
                {
                    "name": "Prefer",
                    "lua_type": "(\"Local\" | \"Graph\")?",
                    "desc": "`\"Local\"`: the local pathfinder first within `LocalRadius`, the graph beyond. `\"Graph\"`: the graph for every route, and the local pathfinder only when the graph has no route (no node in reach, or no chain of links); `LocalRadius` is not used. Pair `\"Graph\"` with `RefineEnds = false` to keep the local pathfinder out of ordinary routes altogether: the graph's entry and exit nodes are chosen on a clear line (its `LineOfSight` option), so the end legs are walked straight. Default `\"Local\"`."
                }
            ],
            "source": {
                "line": 44,
                "path": "lib/Pathfinders/Hybrid.luau"
            }
        }
    ],
    "name": "Hybrid",
    "desc": "A [Types.Pathfinder] that composes a [Graph] for the level and a local pathfinder for the\ngeometry, the way the design plan lays it out. `Name` is `\"Hybrid\"`.\n\nWith `Prefer = \"Graph\"` and `RefineEnds = false` the graph plans everything it can, and the\nlocal pathfinder (Roblox's navmesh, usually) only answers when the graph has no way there.\nAdd a direct walker ([Builder:UseDirect]) and a target in plain view is walked at straight,\nso the navmesh is left for the odd place the graph does not reach. `Blocked` is the local\npathfinder's `Blocked` when it has one, so a blocked local leg re-plans the whole route.",
    "source": {
        "line": 83,
        "path": "lib/Pathfinders/Hybrid.luau"
    }
}