Click or drag to resize

CollidersSafeDestroy Method

Destroys the collider in a way which is safe for physical callback methods.

Namespace:  KSPDev.ModelUtils
Assembly:  KSPDev_Utils.2.5 (in KSPDev_Utils.2.5.dll) Version: 2.5 for KSP v1
Syntax
C#
public static void SafeDestroy(
	Collider obj
)
Request Example View Source

Parameters

obj
Type: UnityEngineCollider
The object to destroy. Can be null.
Remarks
Uses DestroyImmediate to drop the collider when possible. If called during the FixedUpdate cycle, the Destroy is used, and the collider gets explicitly disabled. In the latter case, the collider won't actually be deleted after the call (it will on the next frame update), but it won't be executing any behavior and another collider of the same type could be be added. The caller must always assume that the collider is not immediately removed from the GameObject. Thus, the Collider.enabled property must be checked when fetching the active collider.
See Also