Exemplo n.º 1
0
    private void FixFlappyRotation()
    {
        if (GetComponent <Rigidbody2D>().velocity.y > 0)
        {
            flappyYAxisTravelState = FlappyYAxisTravelState.GoingUp;
        }
        else
        {
            flappyYAxisTravelState = FlappyYAxisTravelState.GoingDown;
        }

        float degreesToAdd = 0;

        switch (flappyYAxisTravelState)
        {
        case FlappyYAxisTravelState.GoingUp:
            degreesToAdd = 6 * RotateUpSpeed;
            break;

        case FlappyYAxisTravelState.GoingDown:
            degreesToAdd = -3 * RotateDownSpeed;
            break;

        default:
            break;
        }
        //solution with negative eulerAngles found here: http://answers.unity3d.com/questions/445191/negative-eular-angles.html

        birdRotation          = new Vector3(0, 0, Mathf.Clamp(birdRotation.z + degreesToAdd, -90, 45));
        transform.eulerAngles = birdRotation;
    }
Exemplo n.º 2
0
    private void FixFlappyRotation()
    {
        if (GetComponent <Rigidbody2D>().velocity.y > 0)
        {
            flappyYAxisTravelState = FlappyYAxisTravelState.GoingUp;
        }
        else
        {
            flappyYAxisTravelState = FlappyYAxisTravelState.GoingDown;
        }

        float degreesToAdd = 0;

        switch (flappyYAxisTravelState)
        {
        case FlappyYAxisTravelState.GoingUp:
            degreesToAdd = 6 * RotateUpSpeed;
            break;

        case FlappyYAxisTravelState.GoingDown:
            degreesToAdd = -3 * RotateDownSpeed;
            break;

        default:
            break;
        }


        //obraca ptaka w ten sposób: -90<rotation<45
        birdRotation          = new Vector3(0, 0, Mathf.Clamp(birdRotation.z + degreesToAdd, -90, 45));
        transform.eulerAngles = birdRotation;
    }
Exemplo n.º 3
0
    /// <summary>
    /// when the flappy goes up, it'll rotate up to 45 degrees. when it falls, rotation will be -90 degrees min
    /// </summary>
    private void FixFlappyRotation()
    {
        if (rigidBody.velocity.y > 0)
        {
            flappyYAxisTravelState = FlappyYAxisTravelState.GoingUp;
        }
        else
        {
            flappyYAxisTravelState = FlappyYAxisTravelState.GoingDown;
        }

        float degreesToAdd = 0;

        switch (flappyYAxisTravelState)
        {
        case FlappyYAxisTravelState.GoingUp:
            degreesToAdd = 6 * RotateUpSpeed;

            break;

        case FlappyYAxisTravelState.GoingDown:
            degreesToAdd = -3 * RotateDownSpeed;
            break;

        default:
            break;
        }

        birdRotation          = new Vector3(0, 0, Mathf.Clamp(birdRotation.z + degreesToAdd, -90, 45));
        transform.eulerAngles = birdRotation;
    }
Exemplo n.º 4
0
    /// <summary>
    /// when the flappy goes up, it'll rotate up to 45 degrees. when it falls, rotation will be -90 degrees min
    /// </summary>
    private void FixFlappyRotation()
    {
        if (GetComponent<Rigidbody2D>().velocity.y > 0) flappyYAxisTravelState = FlappyYAxisTravelState.GoingUp;
        else flappyYAxisTravelState = FlappyYAxisTravelState.GoingDown;

        float degreesToAdd = 0;

        switch (flappyYAxisTravelState)
        {
            case FlappyYAxisTravelState.GoingUp:
                degreesToAdd = 6 * RotateUpSpeed;
                break;
            case FlappyYAxisTravelState.GoingDown:
                degreesToAdd = -3 * RotateDownSpeed;
                break;
            default:
                break;
        }
        //solution with negative eulerAngles found here: http://answers.unity3d.com/questions/445191/negative-eular-angles.html

        //clamp the values so that -90<rotation<45 *always*
        birdRotation = new Vector3(0, 0, Mathf.Clamp(birdRotation.z + degreesToAdd, -90, 45));
        transform.eulerAngles = birdRotation;
    }
Exemplo n.º 5
0
    private void FixRotation()
    {
        if (physics.velocity.y > -2.45f)
        {
            flappyYAxisTravelState = FlappyYAxisTravelState.GoingUp;
        }
        else
        {
            flappyYAxisTravelState = FlappyYAxisTravelState.GoingDown;
        }

        switch (flappyYAxisTravelState)
        {
        case FlappyYAxisTravelState.GoingUp:
            degreesToAdd = GoingUpSpeed;
            break;

        case FlappyYAxisTravelState.GoingDown:
            degreesToAdd = -GoingDownSpeed;
            break;
        }
        birdRotation          = new Vector3(0, 0, Mathf.Clamp(birdRotation.z + degreesToAdd, -MaxDownRotation, MaxUpRotation));
        transform.eulerAngles = birdRotation;
    }