Esempio n. 1
0
    public virtual void GrabHook(Rigidbody2D hookRb)
    {
        hooked = true;

        gameObject.layer = LayerMask.NameToLayer("liftedCrate");

        joint.enabled = true;

        hookScript.GrabHook(this);

        joint.connectedBody   = hookRb;
        joint.connectedAnchor = connectedAnchor;
        joint.anchor          = anchorWhenHooked;
        if (floating != null)
        {
            floating.enabled = false;
        }
    }
Esempio n. 2
0
    protected override void OnTriggerEnter2D(Collider2D other)
    {
        if (dead == true)
        {
            return;
        }
        if (other.tag.Equals("Hook") && hooked == false && other.gameObject != legs)
        {
            HookScript hs = GameObject.FindObjectOfType <HookScript>();
            if (hs == null)
            {
                return;                 //Check if the hook is out
            }
            hs.GrabHook(this);

            hookedTransform = other.transform;
            animator.Play("Hanging");


            GrabHook(other.GetComponent <Rigidbody2D>());
        }
    }