Adding "Per Layer Modifications" causes error

Hello!

Simple but unresolvable issue I have.

As you can see the below screenshot, when I add “Per Layer Modifications” to the gameObject that has AstarPath, simply it shows the error saying “AssertionException: Assertion failure. Value was False. Excepted: True”

All other options of “Add Rule” works but not the layer one.

How can I solve this?

./Packages/com.arongranberg.astar/Graphs/Utilities/UtilityJobs.cs:31)
Pathfinding.Jobs.Slice3D…ctor (Pathfinding.IntBounds outer, Pathfinding.IntBounds slice) (at ./Packages/com.arongranberg.astar/Graphs/Utilities/UtilityJobs.cs:23)
Pathfinding.Graphs.Grid.Rules.RulePerLayerModifications+<>c__DisplayClass4_0.b__0 (Pathfinding.Graphs.Grid.Rules.GridGraphRules+Context context) (at ./Packages/com.arongranberg.astar/Graphs/Grid/Rules/RulePerLayerModifications.cs:53)
Pathfinding.Graphs.Grid.Rules.GridGraphRules.CallActions (System.Collections.Generic.List1[T] actions, Pathfinding.Graphs.Grid.Rules.GridGraphRules+Context context) (at ./Packages/com.arongranberg.astar/Graphs/Grid/Rules/GridGraphRules.cs:120) UnityEngine.Debug:LogException(Exception) Pathfinding.Graphs.Grid.Rules.GridGraphRules:CallActions(List1, Context) (at ./Packages/com.arongranberg.astar/Graphs/Grid/Rules/GridGraphRules.cs:122)
Pathfinding.Graphs.Grid.Rules.d__13:MoveNext() (at ./Packages/com.arongranberg.astar/Graphs/Grid/Rules/GridGraphRules.cs:137)
Pathfinding.d__21:MoveNext() (at ./Packages/com.arongranberg.astar/Graphs/GridGraph.cs:1848)
d__128:MoveNext() (at ./Packages/com.arongranberg.astar/Core/AstarPath.cs:1860)
d__127:MoveNext() (at ./Packages/com.arongranberg.astar/Core/AstarPath.cs:1744)
Pathfinding.AstarPathEditor:MenuScan() (at ./Packages/com.arongranberg.astar/Editor/AstarPathEditor.cs:1366)
Pathfinding.<>c__DisplayClass73_0:b__0() (at ./Packages/com.arongranberg.astar/Editor/AstarPathEditor.cs:826)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions() (at /Users/bokken/build/output/unity/unity/Editor/Mono/EditorApplication.cs:363)

Thanks. That rule can only be used with height testing enabled, which means it cannot be used in 2D mode.
I’ll include a nice error message in the inspector in the next update, and a better error message when scanning.

Thanks for your feedback @aron_granberg

In that case, what is the workaround for 2D games who need to check penalty per each tile? Do you have any examples or video tutorials? The reason I tried to use the above rule is to set a cost in certain grid tile (ex. forest) for controlling agent move speed. In theory, it seems it could be possible if I check all tiles programmatically when the game is launched but any possibility to set those values before the game playing, using Unity Inspector?

Hi

Currently, the best way is to write a custom grid graph rule: Writing Custom Grid Graph Rules - A* Pathfinding Project
Or you can modify all nodes manually: Graph Updates - A* Pathfinding Project (though this is less robust as it doesn’t naturally combine with graph updates).

1 Like

Appreciated it. it helped a lot to me.