예제 #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)");
    }
    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)");
    }