Example #1
0
    protected override void OnDestroy()
    {
//		Debug.Log("Destroying a body: " + _handle);
        if (_handle == IntPtr.Zero)
        {
            Debug.LogError("ChipmunkBody handle is already null.");
            return;
        }

        if (!_isKinematic && CP._cpBodyGetSpace(_handle) != IntPtr.Zero)
        {
            Debug.LogError("Attempted to destroy a ChipmunkBody that was still added to a space.");
            return;
        }

        var gch = GCHandle.FromIntPtr(CP._cpBodyGetUserData(_handle));

        if (gch.Target != this)
        {
            Debug.Log("ChipmunkBody handle does not match");
        }
        gch.Free();
    }