Skip to content

Grid & Snapping — Dynamic Floor Plugin

Grid & Snapping

The Dynamic Floor Plugin does not include built-in grid snapping. However, it provides a dedicated hook where you can implement any positional constraint — grid snapping, vertex snapping, or anything else.


The hook: FindValidHitResult

FindValidHitResult is a function in BP_ExampleRuntimeFloorPolygonToolActor (and any subclass). It receives the raw cursor hit result and returns a validated, optionally transformed position.

Its intended purpose from the official documentation:

“Used to find a valid hit result from the cursor. Can also be used to apply a grid or something.”

The position returned by FindValidHitResult is the position used for:

  • Moving the tool preview (via ShowTool)
  • Creating/finding nodes at that position (via UNodeNetworkSubsystem.getOrCreateNodeAtPosition)
  • Committing the polygon to the database

How to implement grid snapping

1. Subclass the tool

Create a Blueprint subclass of BP_ExampleRuntimeFloorPolygonToolActor.

2. Override FindValidHitResult

In your subclass, override FindValidHitResult. Inside it:

  1. Get the raw hit position from the input hit result.
  2. Round the X and Y components to your grid size:
    SnappedX = Round(RawX / GridSize) * GridSize
    SnappedY = Round(RawY / GridSize) * GridSize
    Z = RawZ (or a fixed height)
  3. Return the snapped position as the valid hit result.

The rest of the tool pipeline will automatically use the snapped position.


How the snapped position flows downstream

Once FindValidHitResult returns a position:

  1. ShowTool moves the tool preview to that position.
  2. On commit (left-click), the position is sent as FFloorInputEvent.Position.
  3. UNodeNetworkSubsystem.getOrCreateNodeAtPosition uses the position to find or create a node — meaning nodes snap to the exact same grid coordinate automatically if two snapped positions are identical.

This means grid snapping also causes node sharing: two wall segments that end on the same grid point will automatically share a node — which is the correct behaviour for a room boundary network.


Vertex snapping (snapping to existing nodes)

The UNodeNetworkSubsystem.getOrCreateNodeAtPosition function returns an existing node if one is already at that position. This means that if your snapped position coincides with an existing node’s position, it will reuse that node rather than creating a new one. This is effectively automatic vertex snapping for grid-aligned positions.

For free-form vertex snapping (snap to nearest node regardless of grid), you would need to query nearby nodes and round to the nearest one’s position manually.


Other uses of FindValidHitResult

The same hook can be used for:

  • Height snapping — lock Z position to fixed floor levels (e.g. floor 1 at Z=0, floor 2 at Z=300)
  • Surface constraints — only allow placement on certain surface types (filter by hit component or material)
  • Exclusion zones — reject hits in restricted areas by returning an invalid result

See also