Esempio n. 1
0
    // Called via player input, Checks if the conditions to be able to rocket jump are met,
    // if so, calls the rocket jump method that performs the rocket jump.
    private void RocketJumpCheck()
    {
        RaycastHit rjBlast_Hit;

        //Determine if the the rocket jump blast hit an object or if it was a mid-air rocket jump, and therefore determine where its center point should be.
        if (Physics.Raycast(firstPersonCam.transform.position, firstPersonCam.transform.forward, out rjBlast_Hit, rjBlast_Range, raycastMask, QueryTriggerInteraction.Ignore))
        {
            //if (rjBlast_Hit.collider != null)
            rjBlast_DidHitSurface = true;
            rjBlast_Epicenter     = rjBlast_Hit.point;
        }
        else
        {
            rjBlast_DidHitSurface = false;
            rjBlast_Epicenter     = firstPersonCam.transform.position + (firstPersonCam.transform.forward * rjBlast_Range);
        }

        firstPersonArms_Animator.Play("Blast", 1, 0.25f);                                  // Play the blast animation.
        BlastForce(rjBlast_Power, rjBlast_Epicenter, rjBlast_Radius, rjBlast_UpwardForce); // Add the blast force to affect other objects.

        if (playerMovement.GetIsGrounded())
        {
            if (playerMovement.GetVerticalCameraAngle() <= -45.0f && playerMovement.GetVerticalCameraAngle() >= -90.0f)
            {
                // Force the player into the air (as if he jumped) before applying the rocket jump to get a compounding force.
                if (autoJumpBeforeGroundedRocketJump)
                {
                    StartCoroutine(JumpThenRocketJump());
                }
                else
                {
                    RocketJump();                  // Rocket jump wihtout jumping first.
                }
            }
        }
        else
        {
            RocketJump();
        }
    }