Esempio n. 1
0
    // Called via the Rocket Jump Check method, this actually performs the rocket jump.
    private void RocketJump()
    {
        rjBlast_TimeSinceLastJump = 0.0f;

        // Test sphere
        if (rj_trainingHitMarker)
        {
            GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            sphere.transform.position = rjBlast_Epicenter;
            Destroy(sphere.GetComponent <SphereCollider>());
            Renderer sphereRend = sphere.GetComponent <Renderer>();
            sphereRend.material = new Material(Shader.Find("Standard"));
            if (rjBlast_DidHitSurface)
            {
                sphereRend.material.color = Color.green;
            }
            else if (rjBlast_NumSinceGrounded < rjBlast_MidAirLimit)
            {
                sphereRend.material.color = Color.yellow;
            }
            else
            {
                sphereRend.material.color = Color.red;
            }
            Destroy(sphere, 5.0f);
        }

        // For testing reset number of mid air jumps if you hit a surface even before touching the ground.
        if (rjBlast_DidHitSurface)
        {
            rjBlast_NumSinceGrounded = 0;
        }

        if (rjBlast_NumSinceGrounded < rjBlast_MidAirLimit)
        {
            // Cancel the downward velocity
            playerRB.AddRelativeForce(new Vector3(0.0f, playerMovement.GetDownwardVelocity() * playerRB.mass, 0.0f), ForceMode.Impulse);

            // Add the rocket jump force
            playerRB.AddExplosionForce(rjBlast_Power, rjBlast_Epicenter, rjBlast_Radius, 0.0f, ForceMode.Impulse);
            if (!playerMovement.GetIsGrounded() && !rjBlast_DidHitSurface)
            {
                rjBlast_NumSinceGrounded += 1;
            }
        }
    }