private void OnTriggerExit2D(Collider2D collision) { if (collision.tag == "gun" && !collision.GetComponent <gunObject>().inHand) { Debug.Log("Player exits: Gun"); this.gunOnFloor = null; } if (collision.tag == "granate" && !collision.GetComponent <granateSkript>().inHand) { Debug.Log("Player exits: Granade"); this.granateOnFloor = null; } }
private void OnTriggerStay2D(Collider2D collision) { if (collision.tag == "gun" && !this.gunOnFloor.inHand) { Debug.Log("Player staying in: Gun"); if (Input.GetMouseButton(1)) { mygun = this.gunOnFloor; mygun.Owner = gameObject; mygun.switchHandState(); } } if (collision.tag == "granate" && !this.granateOnFloor.inHand) { Debug.Log("Player staying in: Granade"); if (Input.GetMouseButton(1)) { myGranate = this.granateOnFloor; myGranate.Owner = gameObject; myGranate.switchHandState(); } } }
private void FixedUpdate() { gunOfPlayer = FindObjectOfType <PlayerMovement>().mygun; granadeOfPlayer = FindObjectOfType <PlayerMovement>().myGranate; }