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; } }
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>()); } }