예제 #1
0
    public void Hold(IItem holdable)
    {
        if (holdable == null)
        {
            return;
        }

        if (currentHeldObject != null)
        {
            Drop(holdable);
        }

        currentHeldObject = holdable;

        CollisionIgnoreManager collisionIgnore = holdable.gameObject.GetComponent<CollisionIgnoreManager>();
        if (collisionIgnore)
        {
            collisionIgnore.otherGameObject = anchorRigidbody.transform.parent.gameObject;
            collisionIgnore.Ignore();
        }

        //holdable.gameObject.transform.SetParent(transform, false);
        holdable.gameObject.transform.position = transform.position;
        holdable.gameObject.transform.rotation = transform.rotation;

        FixedJoint joint = gameObject.AddComponent<FixedJoint>();
        joint.connectedBody = holdable.gameObject.GetComponent<Rigidbody>();

        holdable.OnHold(this);
    }