public void ThrowCog() { //LayerMask teamToIgnore = LayerMask.NameToLayer() myCog.IgnorePlayers(this); myCog.transform.parent = null; myCog.myRB.bodyType = RigidbodyType2D.Dynamic; myCog.GetComponent <Collider2D>().enabled = true; myCog.GetComponentInChildren <Collider2D>().enabled = true; myCog.transform.GetChild(0).gameObject.GetComponent <Collider2D>().enabled = true; //set the physics to ignore this player's teammate //throw the sucker GetComponent <PlayerMovement>().audioSource.PlayOneShot(GetComponent <PlayerMovement>().throwSound); myCog.myRB.velocity = new Vector2(myCog.throwSpeed * throwDir, myCog.throwHeight); myCog = null; }
/*public void OnTriggerExit2D(Collider2D collision) * { * if (collision.GetComponentInParent<CogWheel>()) * { * //Debug.Log("Stepped away"); * cogNearMe = null; * } * }*/ public void PickUp() { myCog = cogNearMe; if (myCog.isDocked()) { myCog.DockToggle(); myCog.transform.parent.gameObject.transform.parent.GetComponent <CogDockController>().RemoveCog(); } GetComponent <PlayerMovement>().audioSource.PlayOneShot(GetComponent <PlayerMovement>().grabSound); myCog.transform.GetChild(0).gameObject.GetComponent <Collider2D>().enabled = false; cogNearMe = null; myCog.transform.parent = heldCogPosit; myCog.transform.position = heldCogPosit.position; myCog.myRB.bodyType = RigidbodyType2D.Kinematic; myCog.GetComponent <Collider2D>().enabled = false; myCog.GetComponentInChildren <Collider2D>().enabled = false; }