示例#1
0
    private void EjectShell()
    {
        WeaponBase activePlayerWeapon = PlayerMain.Instance.ActiveWeapon;

        WeaponBase.Shell shell = activePlayerWeapon.shellPool.getNext();// GameObject.Instantiate(activePlayerWeapon.shellObject);
        shell.gameObject.SetActive(true);
        float ejectMagnitude = Random.Range(activePlayerWeapon.shellEjectionForceMagnitudeMin
                                            , activePlayerWeapon.shellEjectionForceMagnitudeMax);
        Vector3 shellDirection = (activePlayerWeapon.shellEjectionTowardsDirection.transform.position
                                  - activePlayerWeapon.shellEjectionPoint.transform.position).normalized
                                 * ejectMagnitude;

        // + PlayerMain.Instance.GetPlayerMoveDirection();
        shell.gameObject.transform.position = activePlayerWeapon.shellEjectionPoint.transform.position;
        //shell.gameObject.transform.parent = _ammoShellParent.transform.parent;

        /*  shell.rigidBody.AddForce
         *    (shellDirection
         *
         + PlayerMain.Instance.GetInstantaenousVelocity() * 700
         +    )
         +    );*/

        Vector3 shellVelocity = shellDirection
                                + (_firstPersonController.GetInstantaneousVelocity());


        //   * activePlayerWeapon.shellEjectionForceMagnitude ;

        shell.rigidBody.velocity = shellVelocity;
    }
 void LateUpdate()
 {
     MoveValue(ref _smoothenedMoveSpeed, _firstPersonController.GetInstantaneousVelocity().magnitude, _stepValue * Time.deltaTime);
     _weaponSwayAnimator.SetFloat(_movementSpeedBlendParameterName
                                  , _smoothenedMoveSpeed / _firstPersonController.MaxMovementSpeed);
 }