Validate()
Repair the capsule so that it can be used.
Read time 1 minuteLast updated 3 days ago
Definition
- Type: Method
- Namespace: Unity.U2D.Physics
- Assembly: UnityEngine.PhysicsCore2DModule
public readonly CapsuleGeometry Validate()
Returns
Type | Description |
|---|---|
| CapsuleGeometry | The repaired capsule. See _isValid. |
Remarks
The radius is clamped to zero or greater. When the two centers are further apart than _minEdgeLength they are left as they are, otherwise both are replaced with the shortest axis that can still be used. That replacement keeps the direction between the two centers, or points up when they are identical, because a capsule with no length would behave as a circle instead. It does not preserve the original position: a capsule repaired this way is centered on the origin. A non-finite center or radius is not always repaired and can be returned unchanged, so check _isValid when those values might not be finite.