示例#1
0
        public void InitFPSPlayer()
        {
            if (Instance == this)
            {
                _pType = PType.FPS;
                _state = FPSState.DEFAULT;

                if (_gObj == null)
                {
                    _gObj = this.gameObject;
                }

                if (_pCon == null)
                {
                    _pCon = GetComponent <CharacterController>();
                }

                if (_pBod == null)
                {
                    _pBod = GetComponent <Rigidbody>();
                }

                if (_pCam == null)
                {
                    _pCam = GetComponent <Camera>();
                }

                if (_gObj != null && _pCon != null && _pBod != null && _pCam != null)
                {
                    InitHubrisPlayer();
                    Activate();
                }
            }
        }
示例#2
0
        protected override void ProcessGravity()
        {
            if (Active)
            {
                if (!IsGrounded)
                {
                    _gravVector += Physics.gravity * Movement.GravFactor * Time.fixedDeltaTime;

                    if (_prevGrounded)
                    {
                        _fallStartY = this.transform.position.y;
                    }
                }
                else
                {
                    if (_slopeChk >= _pCon.slopeLimit)
                    {
                        _gravVector += _grndChk.normal * Movement.GravBase * Time.fixedDeltaTime;
                        return;
                    }

                    // Set gravVector definitively when grounded
                    _gravVector = new Vector3(0.0f, -Movement.GravBase, 0.0f);

                    // If we were previously airborne
                    if (!_prevGrounded)
                    {
                        // Emit landing sound
                        EmitSoundEvent(new SoundEvent(this, this.transform.position, 60.0f, SoundIntensity.NOTEWORTHY));
                        _state = FPSState.DEFAULT;
                        FallDmgCheck();
                    }
                }

                if (_jumping)
                {
                    _gravVector.y = Movement.JumpSpd;

                    _state   = FPSState.AIRBORNE;
                    _jumping = false;

                    return;
                }
            }
        }