コード例 #1
0
    private void equipWeaponOnPlayerModel(string toEquip)
    {
        //create object from resources, instantiate it on the player (this script runs on the players base transform)
        GameObject itemToAdd = (GameObject)Resources.Load("Prefabs/" + toEquip);

        Instantiate(itemToAdd, this.transform);

        //remove excess copies
        HelperK.removeChild(this.transform, toEquip + "(Clone)");
    }
コード例 #2
0
    private void equipWeaponOnPlayerModel(string toEquip, bool isShield)
    {
        //create object from resources, instantiate it on the player (this script runs on the players base transform)
        GameObject itemToAdd = (GameObject)Resources.Load("Prefabs/" + toEquip);

        Instantiate(itemToAdd, this.transform);

        //attach the weapon to the proper hand, adding in clone to compensate for Unity adding clone to prefabs on awake
        if (isShield == false)
        {
            attachWeaponToRightHand(toEquip + "(Clone)");
        }
        else
        {
            attachWeaponToLeftHand(toEquip + "(Clone)");
        }

        //remove excess copies
        HelperK.removeChild(this.transform, toEquip + "(Clone)");
    }