Skip to content

Random Get Point In Collider 2D

Gets a random world-space point inside a 2D collider.
Supports BoxCollider2D, CircleCollider2D, and CapsuleCollider2D directly.
Other Collider2D types are sampled within their bounds using OverlapPoint.

Use it to spawn objects or effects within an area - such as particles in a region, pickups inside a zone, or enemies in a room.

Parameters

Parameter Description
Collider The Collider2D component to sample from.
Store Result Vector2 variable to store the random world-space point.

Tips

  • Deterministic results: Use Random Init State before running this action if you need reproducible random points.
  • Performance: For complex colliders (like PolygonCollider2D), simplify the shape or use Box/Circle/Capsule for faster sampling.
  • Physics layers: OverlapPoint respects 2D physics and trigger layers - make sure the collider is active and on the correct layer.

Common Pitfalls

  • No Collider set: The action does nothing if no collider is assigned.
  • Non-uniform Circle scale: Uses the largest axis scale to stay inside the true circle.
  • Unsupported shapes: Thin or complex colliders may fail to find a valid point before the 10-attempt limit.

See Also