# Убийство монстра

Данный скрипт навешивается на монстра.

Скрипт содержит метод **monsterKill**, который в начале поворачивает монстра на определённый угол, после чего подключает скрипт **"ccc"**, который удаляет монстра через определённое время.

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

public class eee : MonoBehaviour {

    void Start () {
        // пусто
    }

    void Update () {
        // пусто
    }

    public void monsterKill()
    {
        // поворачиваем объект
        transform.Rotate(-125, 0, 0);
        // добавляем скрипт, отвечающий за удаление чере 5 сек
        gameObject.AddComponent<ccc>();
    }
}
```

Скрипт для стрельбы.

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

public class bbb : MonoBehaviour
{
    public Camera camera = null;

    void Start()
    {
        // пусто
    }

    void Update()
    {
        // при щелчке мышкой
        if (Input.GetMouseButtonDown(0))
        {
            float middleW = camera.pixelWidth / 2;
            float middleH = camera.pixelHeight / 2;
            Vector3 point = new Vector3(middleW, middleH, 0);
            Ray ray = camera.ScreenPointToRay(point);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit))
            {
                // получаем объект, по которому попали
                GameObject hitObj = hit.transform.gameObject;
                // получаем компонент (скрипт) объетка
                // имя компонента должно быть "eee"
                eee s = hitObj.GetComponent<eee>();
                // если такой компонент есть у объекта
                if(s != null)
                {
                    // вызываем метод компонента
                    s.monsterKill();
                }
                else
                {
                    Debug.Log("IT IS NOT MONSTER");
                }
            }
        }
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://maxim218.gitbook.io/unity/ubiistvo-monstra.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
