Forum rules - please read before posting.

Player optionally navigating through Polygon Collider 2d on NPC.

In my 2D game, sometimes I want a polygon collider to block PC pathing (NPC sprite is intentionally blocking the path) sometimes I don't (NPC is in foreground with path behind them in background of sorting map where player is supposed to be able to walk behind them). I could make a separate box collider hotspot for the NPC but having the polygon collider 2D act as the hotspot is super convenient because it automatically matches the transparency of a PNG graphic and doesn't require an extra step if I hide the NPC in the action list with a variable.

So is there a way to sometimes let the player sprite navigate through a polygon collider 2d and sometimes not? I tried deleting the NPC circle collider but that didn't seem to help.


  • Are you looking to disable the Player's ability to navigate any of the NavMesh, or limit their movement to a portion. Screenshots showing the layout will help me understand the situation.

    If you're looking to disable Player movement completely, you can use the Player: Constrain or Engine: Manage systems Actions.

    Otherwise: You can copy/paste a PolygonCollier2D component from the NavMesh onto your NPC - they don't have to be the same object. But, the intended approach to partially block movement is to modify the shape of the NavMesh itself, either by adding/removing holes, or swapping it for another NavMesh completely. Both can be done using the Scene: Change setting Action.

  • So in this first example, the NPC is blocking the path. This may be intentional for a quest. The Polygon Collider 2D is great because it perfectly matches the cutout PNG of the NPC sprite art.

    But in this example, the NPC is still blocking the path because their Poly Collider is in the way of the navmesh. However, it's clear the NPC has moved out of the way so the player should be able to move behind them. However, I don't know how to make a hotspot on the NPC match their graphic without it colliding with the PC sprite movement.

  • In general, colliders associated with Hotspots should have "Is Trigger" checked. This'll prevent them interfering with interfering with collision.

    If you check this option on the NPC's PolygonCollider2D component, they'll still be interactive but the Player should still be able to walk behind them.

  • I knew there had to be a simple solution. Thank you so much as always <3

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.