コード例 #1
0
    //method that will attachWeapons to the left hand player bone.
    private void attachWeaponToLeftHand(string weaponName)
    {
        //Find the weapon object on the Player Character
        Transform weapon = HelperK.FindSearchAllChildren(this.transform, weaponName);

        //Find the lWeaponBone of the player character. Searching through all children.
        Transform lWeaponBone = HelperK.FindSearchAllChildren(this.transform, "LHaveN");

        //Remove any other children from this WeaponBone
        for (int i = 0; i < lWeaponBone.childCount; i++)
        {
            Destroy(lWeaponBone.GetChild(i).gameObject);
        }

        try
        {
            //make the weapon a child of the lWeaponBone, that way it will follow it in all its animations. And place its transform at the handbone location
            weapon.transform.parent = lWeaponBone;
            weapon.transform.SetPositionAndRotation(lWeaponBone.position, lWeaponBone.rotation);

            //compensating for our model rips base rotation being 180degrees off, which extra y rotation due to it being in the opposite of dominant hand
            weapon.transform.Rotate(weapon.transform.rotation.x, weapon.transform.rotation.y + 180, weapon.transform.rotation.z + 180);

            //if a bow do not add an additional base rotation
            if (weapon.name.Contains("Bow"))
            {
                weapon.transform.Rotate(weapon.transform.rotation.x, weapon.transform.rotation.y, weapon.transform.rotation.z + 180);
            }
        }
        catch (MissingComponentException ex)
        {
            Debug.Log("Throwing Null Exception");
        }
    }
コード例 #2
0
    //method that will attachWeapons to the right hand player bone.
    private void attachWeaponToRightHand(string weaponName)
    {
        //Find the weapon object on the Player Character
        //Transform weapon = this.transform.Find(weaponName);
        Transform weapon = HelperK.FindSearchAllChildren(this.transform, weaponName);

        //Find the rWeaponBone of the player character. Searching through all children.
        Transform rWeaponBone = HelperK.FindSearchAllChildren(this.transform, "RHaveN");

        //Remove any other children from this WeaponBone
        for (int i = 0; i < rWeaponBone.childCount; i++)
        {
            Destroy(rWeaponBone.GetChild(i).gameObject);
        }

        try
        {
            //make the weapon a child of the rWeaponBone, that way it will follow it in all its animations. And place its transform at the handbone location
            weapon.transform.parent = rWeaponBone;
            weapon.transform.SetPositionAndRotation(rWeaponBone.position, rWeaponBone.rotation);

            //compensating for our model rips base rotation being 180degrees off,
            weapon.transform.Rotate(weapon.transform.rotation.x, weapon.transform.rotation.y - 90, weapon.transform.rotation.z + 180);
        }
        catch (MissingComponentException ex)
        {
            Debug.Log("Throwing Null Exception");
        }
    }
コード例 #3
0
    private void findEquippedWeapon()
    {
        //find our Main Camera gameObject
        playerWeapon = GameObject.Find("Main Camera");
        //grab our weapon bone
        playerWeapon = HelperK.FindSearchAllChildren(playerWeapon.transform, "WEAPON").gameObject;

        //find the name of the object current the child of our WEAPON bone, this way we dont need to know the name of the weapon currently equipped. We just know where it will be
        playerWeapon = playerWeapon.transform.GetChild(0).gameObject;
    }
コード例 #4
0
    //Initialization of Main Menu states
    void Awake()
    {
        //create instance, setup default states
        Instance = this;

        MainButtonsPanel  = HelperK.FindSearchAllChildren(this.transform, "MainButtonsPanel").gameObject;
        ClassButtonsPanel = HelperK.FindSearchAllChildren(this.transform, "ClassButtonsPanel").gameObject;

        ClassButtonsPanel.SetActive(false);
        MainButtonsPanel.SetActive(true);
    }
コード例 #5
0
    //----------------------------------------------------------------------------BEGIN FUNCTIONS--------------------------------------------------------------------------------------//
    //run on game load (before start)
    void Awake()
    {
        CharacterController = GetComponent("CharacterController") as CharacterController;
        Instance            = this;

        //grab Camera's anchor point, the Head
        cameraAnchorPoint = HelperK.FindSearchAllChildren(this.transform, "AnchorPointHead");

        //grab the Camera focus point, (ie what we are aiming at), and the laserStartPoint for our weapon
        cameraFocusPoint = GameObject.Find("Camera Focus Point");
        laserStartPoint  = GameObject.Find("LaserStartPoint");

        //grab the player models for 1st / 3rd person
        //TODO: Update this to work within all player model status, check model for Player Instance. For now its just testing code
        firstPersonModel = HelperK.FindSearchAllChildren(this.transform, "FatiguesMaleBody");
        thirdPersonModel = HelperK.FindSearchAllChildren(this.transform, "Kaiden");
        changeCameraState();

        //grab the flashlight
        flashlight = HelperK.FindSearchAllChildren(this.transform.parent.transform, "FlashLight").GetComponent <FlashlightController>();
    }