Beispiel #1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        var variance = new Vector2(Random.Range(0f, 0.2f), Random.Range(0f, 0.2f));

        if (hasStarted)
        {
            //GetComponent<Rigidbody2D> ().velocity += variance;
            if (collision.collider.tag == "Player")
            {
                GetComponent <Rigidbody2D> ().velocity = new Vector2(Random.Range(-2f, 2f), Random.Range(1, 4f)).normalized *Speed;
                _hitSound.Play();
            }
            else
            {
                _hitSound.PlayOneShot(Hit);
            }
        }

        if (collision.collider.tag == "Deadline")
        {
            _respawn.DestroyBall(gameObject);
        }
    }