> For the complete documentation index, see [llms.txt](https://maxim218.gitbook.io/unity/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://maxim218.gitbook.io/unity/proverka-stolknoveniya.md).

# Проверка столкновения

```
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class xxx : MonoBehaviour {

    void Start () {
        // делаю данный объект триггером
        gameObject.GetComponent<BoxCollider>().isTrigger = true;
    }

    private void OnTriggerEnter(Collider other)
    {
        // other - объект, с которым произошло столкновение
        // пытаюсь получить компонент (скрипт) объекта
        yyy s = other.GetComponent<yyy>();
        // если у данного объекта есть компонент "yyy"
        if (s != null)
        {
            // вывод сообщения в консоль
            Debug.Log("HIT WITH BALL");
        }
    }
}
```
