コード例 #1
0
ファイル: GrabCog.cs プロジェクト: fshh/GGJ2020
    /*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;
    }