BG Spline Colliders

Colliders pack for BGCurve
Unity Asset Store:

Description

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

How it works

  1. 2D Edge- generates points for attached EdgeCollider 2D.
  2. 3D Box - generate a set of children GameObjects with single attached BoxCollider. GameObjects are positioned and rotated properly.
  3. 2D Box - the same as BGCcCollider3DBox, however children GameObjects may have optional Effector2D attached.
Note: if you use 2d/3d Box 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   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).