public void Equip(Equipable new_item) { // equip the item Debug.Log("equiping - " + new_item.name); if (item) { manager.strength -= item.strength; manager.mana -= item.mana; Destroy(item.gameObject); } item = Instantiate(new_item); Vector3 rot = item.transform.localEulerAngles; item.transform.SetParent(transform); item.transform.localPosition = item.transform.position; item.transform.localEulerAngles = rot; foreach (var coll in item.GetComponentsInChildren <Collider2D>()) { ignore.IgnoreCollider(coll); } var collider = item.GetComponent <Collider2D>(); if (collider) { ignore.IgnoreCollider(collider); } manager.strength += item.strength; manager.mana += item.mana; }
void Start() { limb = GetComponentInParent <Limb>(); controller = GetComponentInParent <StickmanController>(); ig = GetComponentInParent <IgnoreCollision>(); var circleColl = gameObject.AddComponent <CircleCollider2D>(); circleColl.radius = .05f; coll = circleColl; if (ig) { ig.IgnoreCollider(coll); } rb = GetComponent <Rigidbody2D>(); parent = transform; while (parent.parent) { parent = parent.parent; } mask = ~LayerMask.GetMask("Moveable"); joint = gameObject.AddComponent <FixedJoint2D>(); joint.enabled = false; }