コード例 #1
0
ファイル: PlayerJump.cs プロジェクト: setrapp/ShroomCrunk
    private void FixedUpdate()
    {
        var jumpStrength = 0f;
        var jump         = Input.GetAxis($"Jump");

        if (Mathf.Abs(jump) > Helper.Epsilon & !preventingControl)
        {
            bool exclusiveForce = false;
            if (groundTracker.Grounded)
            {
                if (readyToJump)
                {
                    charaAudioJump?.JumpAudio();

                    jumpRemaining  = extraDuration;
                    jumpStrength   = initialJump;
                    exclusiveForce = true;
                    onJump.Invoke();
                }
                else
                {
                    jumpRemaining = 0;
                }
            }
            else
            {
                jumpStrength = extraJump;
                if (requireJumpRelease)
                {
                    readyToJump = false;
                }
            }

            if (jumpRemaining > 0)
            {
                if (normalizeForMass)
                {
                    jumpStrength *= mover.Body.mass;
                }

                // TODO This should be able to work at other orientations (not necessarily based in place)
                var jumpForce = new Vector3(0, jumpStrength, 0);
                mover.ApplyExternalForce(jumpForce, PlayerMover.PlaneComponent.All, exclusiveForce);
                jumpRemaining -= Time.deltaTime;
            }
        }
        else
        {
            readyToJump   = true;
            jumpRemaining = 0;
            onJumpReleased.Invoke();
        }
    }
コード例 #2
0
 public void FinishPound()
 {
     Pounding = true;
     mover.ApplyExternalForce(Vector3.down * poundStrength, true);
 }