Example #1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Ghost")
        {
            print("Столкновение");
        }

        //Изменяем скорость при столкновении с обьектом
        if (collision.gameObject.TryGetComponent <MovableObject>(out movable))
        {
            if (!ground.IsTouching(collision.gameObject.GetComponent <BoxCollider2D>()))
            {
                tempVelocity = acceleration;
                movable.ChangeVelocity(ref acceleration);
            }
        }
    }