Exemplo n.º 1
0
        private void PutWeaponInHand(WeaponConfig weapon)
        {
            if (weaponObject != null)
            {
                Destroy(weaponObject);
            }
            Transform weaponSocket = null;

            switch (weapon.GetHand())
            {
            case Hand.OffHand:
                weaponSocket = RequestOffHand();
                break;

            case Hand.DominantHand:
                weaponSocket = RequestDominantHand();
                break;
            }

            weaponObject = Instantiate(weapon.GetWeaponPrefab(), weaponSocket);
            var weaponGrip = weapon.getWeaponGrip();

            weaponObject.transform.localPosition = weaponGrip.transform.position;
            weaponObject.transform.localRotation = weaponGrip.transform.rotation;
            weaponObject.transform.localScale    = weaponGrip.transform.localScale;

            animator.SetFloat("AttackAnimationSpeedMultiplier", weapon.GetAttackSpeedMultiplier());
            heldWeapon = weapon;
        }
Exemplo n.º 2
0
        private void UpdateWeapon()
        {
            cachedConfig = weaponConfig;
            DestroyAllChildren();
            var weaponObject = Instantiate(weaponConfig.GetWeaponPrefab(), transform);

            weaponObject.transform.localPosition = Vector3.zero;
        }
Exemplo n.º 3
0
        private void DoEditModeUpdate()
        {
            if (cachedConfig == null)
            {
                cachedConfig = weaponConfig;
            }

            if (cachedConfig != weaponConfig)
            {
                UpdateWeapon();
            }
        }