Exemplo n.º 1
0
    public virtual bool Detach(HardpointController point)
    {
        AttachmentController attachment = point.Attached;

        if (attachment == null)
        {
            return(false);
        }

        if (!attachment.OnDetach())
        {
            return(false);
        }

        FixedJoint[] joints = gameObject.GetComponents <FixedJoint>();
        foreach (FixedJoint joint in joints)
        {
            if (joint.connectedBody == attachment.rigidbody)
            {
                joint.connectedBody = null;
                Destroy(joint);
            }
        }

        point.Detach();
        attachment.rigidbody.AddForceAtPosition(point.transform.up * 10, point.transform.position);

        return(true);
    }