Ejemplo n.º 1
0
        /// <summary>
        /// Adds an input restriction on the given <see cref="FirstPersonMover"/>
        /// </summary>
        /// <param name="firstPersonMover">The target to add a restriction to</param>
        /// <param name="inputRestriction">A bitfield of input restrictions to apply</param>
        public static void AddRestriction(FirstPersonMover firstPersonMover, InputRestrictions inputRestriction)
        {
            validateInputRestrictions(inputRestriction);

            if (!_characterInputRestrictions.ContainsKey(firstPersonMover))
            {
                _characterInputRestrictions.Add(firstPersonMover, 0);
            }

            _characterInputRestrictions[firstPersonMover] |= inputRestriction;

            firstPersonMover.AddDeathListener(filterDictionary);
        }
Ejemplo n.º 2
0
        void Awake()
        {
            _timeToActivateInput = Time.time + 0.5f;

            _owner = GetComponent <FirstPersonMover>();
            if (_owner == null)
            {
                throw new MissingComponentException("VR player must be on the same GameObject as a FirstPersonMover");
            }

            _head = _owner.GetBodyPart(MechBodyPartType.Head).transform.parent.gameObject;
            _head.SetActive(false);
            _rightHand = _owner.GetBodyPart(MechBodyPartType.RightArm).transform.parent.gameObject;
            _leftHand  = _owner.GetBodyPart(MechBodyPartType.LeftArm).transform.parent.gameObject;

            _owner.AddDeathListener(OnPlayerDeath);

            if (_rightHand == null)
            {
                throw new Exception("Right hand is null");
            }
            if (_leftHand == null)
            {
                throw new Exception("Left hand is null");
            }

            Transform armLowerL = _leftHand.transform.parent;
            Transform armUpperL = armLowerL.parent;

            Transform armLowerR = _rightHand.transform.parent;
            Transform armUpperR = armLowerR.parent;

            Transform ArmsRoot = armUpperL.parent;


            _leftArmIK = armUpperL.gameObject.AddComponent <LimbIK>();
            _leftArmIK.solver.SetChain(armUpperL, armLowerL, _leftHand.transform, ArmsRoot);

            _rightArmIK = armUpperR.gameObject.AddComponent <LimbIK>();
            _rightArmIK.solver.SetChain(armUpperR, armLowerR, _rightHand.transform, ArmsRoot);

            VRManager.Instance.Player.Scale = transform.localScale.y * 1.4f;
        }