Unity provides standard spline asset, use BGCurve only if Unity spline misses some feature

BG Spline Colliders

Colliders pack for BGCurve
Unity Asset Store:

Description

Colliders pack consists of 6 components for BG Curve, which generate colliders along Bezier spline.

How it works

  1. 3D Box - generate a set of children GameObjects with attached BoxCollider. GameObjects are positioned and rotated properly.
  2. Capsule - generate a set of children GameObjects with attached CapsuleCollider. GameObjects are positioned and rotated properly.
  3. 3D Mesh - generate positions for MeshFilter inside 2D spline.
  4. 2D Edge- generates points for attached EdgeCollider 2D.
  5. 2D Box - the same as BGCcCollider3DBox, however children GameObjects may have optional Effector2D attached.
  6. 2D Mesh - generate positions for PolygonCollider 2D inside 2D spline.
Note: if you use 2d/3d Box or Capsule Colliders, please, do not attach your own 2d/3d box colliders to child GameObjects right under the spline, cause they may be reused and deleted.

How to change spline with colliders at runtime

  1. Animate spline with script or Unity animation (more info)
  2. Set "Math Type" parameter of Math component to "Base". Adjust "Section Parts" parameter value to be as little as possible
  3. For 2d/3d box components, toggle on "Generate kinematic rigidbodies" parameter. For 2d edge, add RigidBody2D component and toggle "isKinematic" on
Generate a set of   Box colliders   for 3D spline
  1. Create a spline (Video Tutorial)   (Text Guide)
  2. Turn on snapping (Under Points tab) if you need it. Setup "Snap Layer Mask" for collisions.
  3. Add "Collider 3D Box" component (under Components tab). This component reuses 1 level children GameObjects with BoxCollider attached, so do not place any additional BoxColliders under spline's GameObject.
  4. Adjust Resolution. You can adjust the number of points you want to split the spline to by adjusting Math's components properties (if you set SplitMode to 'UseMathData'), or you can change SplitMode to PartsTotal or PartsPerSection and assign the number os splits directly. We recommend to set SplitMode to 'UseMathData' (default) and change MathType of Math component to Adaptive and adjust Tolerance.
  5. Adjust "Collider 3D Box" component properties if needed (like Width, Heigth, OffSet etc.)
Generate a set of   Capsule colliders   for 3D spline
  1. Create a spline (Video Tutorial)   (Text Guide)
  2. Turn on snapping (Under Points tab) if you need it. Setup "Snap Layer Mask" for collisions.
  3. Add "Collider Capsule" component (under Components tab). This component reuses 1 level children GameObjects with CapsuleCollider attached, so do not place any additional CapsuleColliders under spline's GameObject.
  4. Adjust Resolution. You can adjust the number of points you want to split the spline to by adjusting Math's components properties (if you set SplitMode to 'UseMathData'), or you can change SplitMode to PartsTotal or PartsPerSection and assign the number os splits directly. We recommend to set SplitMode to 'UseMathData' (default) and change MathType of Math component to Adaptive and adjust Tolerance.
  5. Adjust "Collider Capsule" component properties if needed (like Radius and LengthExtends etc.)
Generates positions for Mesh Collider inside the spline. Spline should be in 2D mode. Simple polygons only (no intersections).
  1. Create a spline (Video Tutorial)   (Text Guide)
  2. Set spline's 2D Mode to XY (under Points tab).
  3. Add "Collider 3D Mesh" component (under Components tab).
Generate a set of   Box Colliders 2D   for 2D spline
  1. Create a spline (Video Tutorial)   (Text Guide)
  2. Set spline's 2D Mode to XY (under Points tab).
  3. Add "Collider 2D Box" component (under Components tab). This component reuses 1 level children GameObjects with BoxCollider2D attached, so do not place any additional BoxCollider2D under spline's GameObject.
  4. Adjust Resolution. You can adjust the number of points you want to split the spline to by adjusting Math's components properties (if you set SplitMode to 'UseMathData'), or you can change SplitMode to PartsTotal or PartsPerSection and assign the number os splits directly. We recommend to set SplitMode to 'UseMathData' (default) and change MathType of Math component to Adaptive and adjust Tolerance.
  5. Adjust "Collider 2D Box" component properties if needed (like Heigth, OffSet etc.)
Generate points positions for   Edge Collider 2D   Unity's Component for 2D spline
  1. Create a spline (Video Tutorial)   (Text Guide)
  2. Set spline's 2D Mode to XY (under Points tab).
  3. Add "Collider 2D Edge" component (under Components tab).
Generates positions for Polygon Collider 2D inside the spline
  1. Create a spline (Video Tutorial)   (Text Guide)
  2. Set spline's 2D Mode to XY (under Points tab).
  3. Add "Collider 2D Mesh" component (under Components tab).