How angry bird's "GAME OVER" system work?

I just started using unity, so I’m not much familiar with it! And I’m also trying to make a
“2d angry birds style” game. But I had a quit struggle with how game over system work in angry birds.
I tried to write a code that would take the player position and check it a second later and if the differences in each axes was lower than a specific number, then it would call the “GAME OVER” function from game manager. But sure it was a massive failure. So … uh … can anyone please help me? or gimme a
better idea? Cause I’ll be really thankful.

can you explain what you did and what exactly do you want...i am unable to pinpoint what the problem is here

2 Answers

2

If you are using the unity gravity, you can check the Rigidbody.velocity and if each direction are less than 0.1f for like 2 seconds call the game over function. Something like that :

    [SerializeField] Rigidbody2D _rb; // BIRD RIGIDBODY
    float _time; //time when the bird is throwed
    bool _ABirdIsTrowed;

    private void Update()
    {
        if (_ABirdIsTrowed)
        {
            if (_rb.velocity.x >= 0.1f || _rb.velocity.y >= 0.1f) // the velocity is bigger than 0.1f so he's moving
            {
                _time = Time.time; // reset the timer
            }
            if (_time - Time.time >= 2f) // it's been 2 seconds and the bird didn t moved
            {
                GameOver();
            }
        }
    }

Thank you very much! It works perfectly :slight_smile: