{"id":291941,"date":"2019-07-11T09:02:11","date_gmt":"2019-07-11T09:02:11","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=291941"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=291941","title":{"rendered":"\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438\u0433\u0440\u044b Tower Defense \u0432 Unity: \u0431\u0430\u0448\u043d\u0438 \u0438 \u0441\u0442\u0440\u0435\u043b\u044c\u0431\u0430 \u043f\u043e \u0432\u0440\u0430\u0433\u0430\u043c"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">[<a href=\"https:\/\/habr.com\/ru\/post\/449798\/\">\u041f\u0435\u0440\u0432\u0430\u044f<\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/post\/452756\/\">\u0432\u0442\u043e\u0440\u0430\u044f<\/a> \u0447\u0430\u0441\u0442\u0438 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430]<\/p>\n<ul>\n<li>\u0420\u0430\u0437\u043c\u0435\u0449\u0430\u0435\u043c \u043d\u0430 \u043f\u043e\u043b\u0435 \u0431\u0430\u0448\u043d\u0438.<\/li>\n<li>\u0426\u0435\u043b\u0438\u043c\u0441\u044f \u0432\u043e \u0432\u0440\u0430\u0433\u043e\u0432 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0444\u0438\u0437\u0438\u043a\u0438.<\/li>\n<li>\u041e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u043c \u0438\u0445, \u043f\u043e\u043a\u0430 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e.<\/li>\n<li>\u0421\u0442\u0440\u0435\u043b\u044f\u0435\u043c \u0432 \u043d\u0438\u0445 \u043b\u0430\u0437\u0435\u0440\u043d\u044b\u043c \u043b\u0443\u0447\u043e\u043c.<\/li>\n<\/ul>\n<p>  \u042d\u0442\u043e \u0442\u0440\u0435\u0442\u044c\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u0435\u0440\u0438\u0438 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u043e\u0432 \u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438\u0433\u0440\u044b \u0436\u0430\u043d\u0440\u0430 tower defense. \u0412 \u043d\u0435\u0439 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0431\u0430\u0448\u0435\u043d, \u043f\u0440\u0438\u0446\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u0435 \u0438 \u0441\u0442\u0440\u0435\u043b\u044c\u0431\u0430 \u0432\u043e \u0432\u0440\u0430\u0433\u043e\u0432.<\/p>\n<p>  \u0422\u0443\u0442\u043e\u0440\u0438\u0430\u043b \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0441\u044f \u0432 Unity 2018.3.0f2.<\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/470\/ceb\/183\/470ceb1832b49ee7372fb79b8425b567.jpg\" width=\"512\" height=\"256\"><\/div>\n<p>  <i>\u0417\u0430\u0434\u0430\u0434\u0438\u043c \u0432\u0440\u0430\u0433\u0430\u043c \u0436\u0430\u0440\u0443.<\/i><\/p>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0431\u0430\u0448\u043d\u0438<\/h2>\n<p>  \u0421\u0442\u0435\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u044e\u0442 \u0432\u0440\u0430\u0433\u043e\u0432, \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u044f \u0434\u043b\u0438\u043d\u0443 \u043f\u0443\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0439\u0442\u0438. \u041d\u043e \u0446\u0435\u043b\u044c \u0438\u0433\u0440\u044b \u2014 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0438\u0442\u044c \u0432\u0440\u0430\u0433\u043e\u0432, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043e\u043d\u0438 \u0434\u043e\u0431\u0435\u0440\u0443\u0442\u0441\u044f \u0434\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438. \u042d\u0442\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0435\u043c \u043d\u0430 \u043f\u043e\u043b\u0435 \u0431\u0430\u0448\u0435\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e \u043d\u0438\u043c \u0441\u0442\u0440\u0435\u043b\u044f\u0442\u044c.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h3>\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0442\u0430\u0439\u043b\u0430<\/h3>\n<p>  \u0411\u0430\u0448\u043d\u0438 \u2014 \u044d\u0442\u043e \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0442\u0438\u043f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u0442\u0430\u0439\u043b\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0434\u043b\u044f \u043d\u0438\u0445 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 <code>GameTileContent<\/code>.<\/p>\n<pre><code class=\"cs\">public enum GameTileContentType { \tEmpty, Destination, Wall, SpawnPoint, Tower\u20ac }<\/code><\/pre>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0442\u0438\u043f \u0431\u0430\u0448\u0435\u043d, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0432 <code>GameTileContentFactory<\/code> \u043e\u0434\u043d\u0443 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043f\u0440\u0435\u0444\u0430\u0431 \u0431\u0430\u0448\u043d\u0438, \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 <code>Get<\/code>.<\/p>\n<pre><code class=\"cs\">\t[SerializeField] \tGameTileContent towerPrefab = default;  \tpublic GameTileContent Get (GameTileContentType type) { \t\tswitch (type) { \t\t\t\u2026 \t\t\tcase GameTileContentType.Tower\u20ac: return Get(towerPrefab); \t\t} \t\t\u2026 \t}<\/code><\/pre>\n<p>  \u041d\u043e \u0431\u0430\u0448\u043d\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u0442\u0440\u0435\u043b\u044f\u0442\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0445 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0438 \u0438\u043c \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0446\u0435\u043b\u0438 \u043a\u043b\u0430\u0441\u0441 <code>Tower<\/code>, \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u044e\u0449\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 <code>GameTileContent<\/code>.<\/p>\n<pre><code class=\"cs\">using UnityEngine;  public class Tower : GameTileContent {}<\/code><\/pre>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u0444\u0430\u0431 \u0431\u0430\u0448\u043d\u0438 \u0438\u043c\u0435\u043b \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442, \u0438\u0437\u043c\u0435\u043d\u0438\u0432 \u0442\u0438\u043f \u043f\u043e\u043b\u044f \u0444\u0430\u0431\u0440\u0438\u043a\u0438 \u043d\u0430 <code>Tower<\/code>. \u0422\u0430\u043a \u043a\u0430\u043a \u043a\u043b\u0430\u0441\u0441 \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f <code>GameTileContent<\/code>, \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e.<\/p>\n<pre><code class=\"cs\">\tTower towerPrefab = default;<\/code><\/pre>\n<p>  <\/p>\n<h3>\u041f\u0440\u0435\u0444\u0430\u0431<\/h3>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u0435\u0444\u0430\u0431 \u0434\u043b\u044f \u0431\u0430\u0448\u043d\u0438. \u041c\u043e\u0436\u043d\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u0441 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0435\u0444\u0430\u0431\u0430 \u0441\u0442\u0435\u043d\u044b \u0438 \u0437\u0430\u043c\u0435\u043d\u044b \u0435\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 <code>GameTileContent<\/code> \u043d\u0430 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 <code>Tower<\/code>, \u0430 \u043f\u043e\u0441\u043b\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u0442\u0438\u043f \u043d\u0430 <em>Tower<\/em>. \u0427\u0442\u043e\u0431\u044b \u0431\u0430\u0448\u043d\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0430 \u043f\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0443 \u0441\u0442\u0435\u043d\u0430\u043c, \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u043a\u0443\u0431 \u0441\u0442\u0435\u043d\u044b \u043a\u0430\u043a \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0430\u0448\u043d\u0438. \u0417\u0430\u0442\u0435\u043c \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u0435 \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u043a\u0443\u0431 \u043f\u043e\u0432\u0435\u0440\u0445 \u043d\u0435\u0433\u043e. \u042f \u0437\u0430\u0434\u0430\u043b \u0435\u043c\u0443 \u043c\u0430\u0441\u0448\u0442\u0430\u0431 0.5. \u041f\u043e\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u043d\u0430 \u043d\u0435\u0433\u043e \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u043a\u0443\u0431, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0438\u0439 \u0442\u0443\u0440\u0435\u043b\u044c, \u044d\u0442\u0430 \u0447\u0430\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u0446\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0438 \u0441\u0442\u0440\u0435\u043b\u044f\u0442\u044c \u0432\u043e \u0432\u0440\u0430\u0433\u043e\u0432.<\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/392\/e5d\/633\/392e5d63397672627c3b5ec018df0444.png\" width=\"190\" height=\"260\"><\/div>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/d92\/dec\/c33\/d92decc33036a1e973a7f20a3df2c00e.png\" width=\"320\" height=\"120\"><\/div>\n<p>  <i>\u0422\u0440\u0438 \u043a\u0443\u0431\u0430, \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0449\u0438\u0445 \u0431\u0430\u0448\u043d\u044e.<\/i><\/p>\n<p>  \u0422\u0443\u0440\u0435\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f, \u0438 \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d\u0430 \u0438\u043c\u0435\u0435\u0442 \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440, \u0435\u0451 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0434\u0432\u0438\u0436\u043e\u043a. \u041d\u043e \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0442\u0430\u043a\u0438\u043c\u0438 \u0442\u043e\u0447\u043d\u044b\u043c\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440\u044b \u0431\u0430\u0448\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u044f\u0447\u0435\u0435\u043a. \u042d\u0442\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e. \u0423\u0434\u0430\u043b\u0438\u0442\u0435 \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440 \u043a\u0443\u0431\u0430 \u0442\u0443\u0440\u0435\u043b\u0438 \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0435 \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440 \u043a\u0443\u0431\u0430 \u0431\u0430\u0448\u043d\u0438, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u043b \u043e\u0431\u0430 \u043a\u0443\u0431\u0430.<\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e01\/11e\/3b7\/e0111e3b7221bbbe4e5b0d23373e4b3a.png\" width=\"190\" height=\"260\"><\/div>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/a1f\/857\/09b\/a1f85709bd504d176a18930240edea5a.png\" width=\"320\" height=\"152\"><\/div>\n<p>  <i>\u041a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440 \u043a\u0443\u0431\u0430 \u0431\u0430\u0448\u043d\u0438.<\/i><\/p>\n<p>  \u0411\u0430\u0448\u043d\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u0440\u0435\u043b\u044f\u0442\u044c \u043b\u0430\u0437\u0435\u0440\u043d\u044b\u043c \u043b\u0443\u0447\u043e\u043c. \u0415\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438, \u043d\u043e \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u043e\u043b\u0443\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u0439 \u043a\u0443\u0431, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0441\u0442\u044f\u043d\u0435\u043c \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043b\u0443\u0447\u0430. \u0423 \u043a\u0430\u0436\u0434\u043e\u0439 \u0431\u0430\u0448\u043d\u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043b\u0443\u0447, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0433\u043e \u043a \u043f\u0440\u0435\u0444\u0430\u0431\u0443 \u0431\u0430\u0448\u043d\u0438. \u0420\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0438\u043c \u0435\u0433 \u0432\u043d\u0443\u0442\u0440\u0438 \u0442\u0443\u0440\u0435\u043b\u0438, \u0447\u0442\u043e\u0431\u044b \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043e\u043d \u0431\u044b\u043b \u0441\u043a\u0440\u044b\u0442, \u0438 \u043f\u0440\u0438\u0434\u0430\u0434\u0438\u043c \u0435\u043c\u0443 \u043c\u0435\u043d\u044c\u0448\u0438\u0439 \u043c\u0430\u0441\u0448\u0442\u0430\u0431, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 0.2. \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0435\u0433\u043e \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u043a\u043e\u0440\u043d\u044f \u043f\u0440\u0435\u0444\u0430\u0431\u0430, \u0430 \u043d\u0435 \u043a\u0443\u0431\u0430 \u0442\u0443\u0440\u0435\u043b\u0438.<\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/19a\/1dc\/29e\/19a1dc29e70adb158e07f29653db2d66.png\" width=\"190\" height=\"260\" alt=\"laser beam\"><\/div>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/45a\/273\/081\/45a273081365aa9e483f1aa97cbe39c8.png\" width=\"226\" height=\"108\" alt=\"hierarchy\"><\/div>\n<p>  <i>\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u0443\u0431 \u043b\u0430\u0437\u0435\u0440\u043d\u043e\u0433\u043e \u043b\u0443\u0447\u0430.<\/i><\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u043b\u044f \u043b\u0430\u0437\u0435\u0440\u043d\u043e\u0433\u043e \u043b\u0443\u0447\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b. \u042f \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043f\u043e\u043b\u0443\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u0439 \u0447\u0451\u0440\u043d\u044b\u0439 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u043b \u0432\u0441\u0435 \u043e\u0442\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u0434\u0430\u043b \u0435\u043c\u0443 \u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u0438\u0441\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u044b\u0439 \u0446\u0432\u0435\u0442.<\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/2fb\/e49\/860\/2fbe498604cc4cc4ed6ee60a45eea63d.png\" width=\"320\" height=\"284\" alt=\"color\"><\/div>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/0eb\/b46\/483\/0ebb4648376a7fe68c96b7a16ce27db9.png\" width=\"320\" height=\"56\" alt=\"no reflections\"><\/div>\n<p>  <i>\u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043b\u0430\u0437\u0435\u0440\u043d\u043e\u0433\u043e \u043b\u0443\u0447\u0430.<\/i><\/p>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435, \u0447\u0442\u043e\u0431\u044b \u0443 \u043b\u0430\u0437\u0435\u0440\u043d\u043e\u0433\u043e \u043b\u0443\u0447\u0430 \u043d\u0435 \u0431\u044b\u043b\u043e \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u0435 \u0443 \u043d\u0435\u0433\u043e \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043d\u0438\u0435 \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0442\u0435\u043d\u0435\u0439.<\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/ecf\/f21\/0ad\/ecff210ad75ef4b12cb0a74102365492.png\" width=\"320\" height=\"162\"><\/div>\n<p>  <i>\u041b\u0430\u0437\u0435\u0440\u043d\u044b\u0439 \u043b\u0443\u0447 \u043d\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u0441 \u0442\u0435\u043d\u044f\u043c\u0438.<\/i><\/p>\n<p>  \u0417\u0430\u0432\u0435\u0440\u0448\u0438\u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u0435\u0444\u0430\u0431\u0430 \u0431\u0430\u0448\u043d\u0438, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0433\u043e \u0432 \u0444\u0430\u0431\u0440\u0438\u043a\u0443.<\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/626\/37c\/935\/62637c9353cf1e20e170e82bbefcdb11.png\" width=\"320\" height=\"114\"><\/div>\n<p>  <i>\u0424\u0430\u0431\u0440\u0438\u043a\u0430 \u0441 \u0431\u0430\u0448\u043d\u0435\u0439.<\/i><\/p>\n<h3>\u0420\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0431\u0430\u0448\u0435\u043d<\/h3>\n<p>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0438 \u0443\u0431\u0438\u0440\u0430\u0442\u044c \u0431\u0430\u0448\u043d\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0435\u0449\u0451 \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f. \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c <code>GameBoard.ToggleWall<\/code>, \u0438\u0437\u043c\u0435\u043d\u0438\u0432 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 \u0438 \u0442\u0438\u043f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e.<\/p>\n<pre><code class=\"cs\">\tpublic void ToggleTower (GameTile tile) { \t\tif (tile.Content.Type == GameTileContentType.Tower\u20ac) { \t\t\ttile.Content = contentFactory.Get(GameTileContentType.Empty); \t\t\tFindPaths(); \t\t} \t\telse if (tile.Content.Type == GameTileContentType.Empty) { \t\t\ttile.Content = contentFactory.Get(GameTileContentType.Tower\u20ac); \t\t\tif (!FindPaths()) { \t\t\t\ttile.Content = contentFactory.Get(GameTileContentType.Empty); \t\t\t\tFindPaths(); \t\t\t} \t\t} \t}<\/code><\/pre>\n<p>  \u0412 <code>Game.HandleTouch<\/code> \u043f\u0440\u0438 \u0437\u0430\u0436\u0430\u0442\u0438\u0438 \u043a\u043b\u0430\u0432\u0438\u0448\u0438 shift \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u0431\u0443\u0434\u0443\u0442 \u043d\u0435 \u0441\u0442\u0435\u043d\u044b, \u0430 \u0431\u0430\u0448\u043d\u0438.<\/p>\n<pre><code class=\"cs\">\tvoid HandleTouch () { \t\tGameTile tile = board.GetTile(TouchRay); \t\tif (tile != null) { \t\t\tif (Input.GetKey(KeyCode.LeftShift)) { \t\t\t\tboard.ToggleTower(tile); \t\t\t} \t\t\telse { \t\t\t\tboard.ToggleWall(tile); \t\t\t} \t\t} \t}<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/926\/804\/2ac\/9268042acc19a28d6ff1a6d74d83144f.png\" width=\"230\" height=\"230\"><\/div>\n<p>  <i>\u0411\u0430\u0448\u043d\u0438 \u043d\u0430 \u043f\u043e\u043b\u0435.<\/i><\/p>\n<h3>\u0411\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0443\u0442\u0438<\/h3>\n<p>  \u041f\u043e\u043a\u0430 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0438\u0441\u043a \u043f\u0443\u0442\u0438 \u043c\u043e\u0433\u0443\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0435\u043d\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0440\u0430\u0433\u0438 \u0434\u0432\u0438\u0436\u0443\u0442\u0441\u044f \u0441\u043a\u0432\u043e\u0437\u044c \u0431\u0430\u0448\u043d\u0438. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 <code>GameTileContent<\/code> \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0435\u0435, \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 \u043b\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043f\u0443\u0442\u044c. \u041f\u0443\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0441\u0442\u0435\u043d\u0430 \u0438\u043b\u0438 \u0431\u0430\u0448\u043d\u044f.<\/p>\n<pre><code class=\"cs\">\tpublic bool BlocksPath =&gt; \t\tType == GameTileContentType.Wall || Type == GameTileContentType.Tower\u20ac;<\/code><\/pre>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u044d\u0442\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0432 <code>GameTile.GrowPathTo<\/code> \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0442\u0438\u043f\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e.<\/p>\n<pre><code class=\"cs\">\tGameTile GrowPathTo (GameTile neighbor, Direction direction) { \t\t\u2026 \t\treturn \t\t\t\/\/neighbor.Content.Type != GameTileContentType.Wall ? neighbor : null; \t\t\tneighbor.Content.BlocksPath ? null : neighbor; \t}<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6fa\/93f\/eed\/6fa93feedb4925ee12decb4233612a4c.png\" width=\"230\" height=\"230\"><\/div>\n<p>  <i>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0443\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0442 \u0438 \u0441\u0442\u0435\u043d\u044b, \u0438 \u0431\u0430\u0448\u043d\u0438.<\/i><\/p>\n<h3>\u0417\u0430\u043c\u0435\u043d\u044f\u0435\u043c \u0441\u0442\u0435\u043d\u044b<\/h3>\n<p>  \u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0438\u0433\u0440\u043e\u043a \u0431\u0443\u0434\u0435\u0442 \u0447\u0430\u0441\u0442\u043e \u0437\u0430\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0442\u0435\u043d\u044b \u0431\u0430\u0448\u043d\u044f\u043c\u0438. \u0415\u043c\u0443 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0431\u0438\u0440\u0430\u0442\u044c \u0441\u0442\u0435\u043d\u0443, \u0438 \u043a \u0442\u043e\u043c\u0443 \u0436\u0435 \u0432 \u044d\u0442\u043e\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044f\u0432\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u043a \u0441\u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u043e\u043d\u0438\u043a\u0430\u0442\u044c \u0432\u0440\u0430\u0433\u0438. \u041c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u044f\u043c\u0443\u044e \u0437\u0430\u043c\u0435\u043d\u0443, \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0432 <code>GameBoard.ToggleTower<\/code> \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c, \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043b\u0438 \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430 \u0442\u0430\u0439\u043b\u0435 \u0441\u0442\u0435\u043d\u0430. \u0415\u0441\u043b\u0438 \u0434\u0430, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0451 \u043d\u0430 \u0431\u0430\u0448\u043d\u044e. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043d\u0435 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0438\u0441\u043a\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0443\u0442\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0442\u0430\u0439\u043b \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0438\u0445 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442.<\/p>\n<pre><code class=\"cs\">\tpublic void ToggleTower (GameTile tile) { \t\tif (tile.Content.Type == GameTileContentType.Tower) { \t\t\ttile.Content = contentFactory.Get(GameTileContentType.Empty); \t\t\tFindPaths(); \t\t} \t\telse if (tile.Content.Type == GameTileContentType.Empty) { \t\t\t\u2026 \t\t} \t\telse if (tile.Content.Type == GameTileContentType.Wall) { \t\t\ttile.Content = contentFactory.Get(GameTileContentType.Tower); \t\t} \t}<\/code><\/pre>\n<p>  <\/p>\n<h2>\u0426\u0435\u043b\u0438\u043c\u0441\u044f \u0432\u043e \u0432\u0440\u0430\u0433\u043e\u0432<\/h2>\n<p>  \u0411\u0430\u0448\u043d\u044f \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0441\u0432\u043e\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0439\u0434\u0451\u0442 \u0432\u0440\u0430\u0433\u0430. \u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0432\u0440\u0430\u0433\u0430 \u043e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0440\u0435\u0448\u0438\u0442\u044c, \u0432 \u043a\u0430\u043a\u0443\u044e \u0435\u0433\u043e \u0447\u0430\u0441\u0442\u044c \u043d\u0443\u0436\u043d\u043e \u0446\u0435\u043b\u0438\u0442\u044c\u0441\u044f.<\/p>\n<h3>\u0422\u043e\u0447\u043a\u0430 \u043f\u0440\u0438\u0446\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f<\/h3>\n<p>  \u0414\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0446\u0435\u043b\u0435\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0434\u0432\u0438\u0436\u043e\u043a. \u041a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440\u043e\u043c \u0431\u0430\u0448\u043d\u0438, \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440 \u0432\u0440\u0430\u0433\u0430 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u043b \u0441 \u0435\u0433\u043e \u0444\u043e\u0440\u043c\u043e\u0439. \u041c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440, \u0442\u043e \u0435\u0441\u0442\u044c \u0441\u0444\u0435\u0440\u0443. \u041f\u043e\u0441\u043b\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0432\u0440\u0430\u0433\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0438\u0433\u0440\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441 \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0451\u043d\u043d\u044b\u043c \u043a \u043d\u0435\u043c\u0443 \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440\u043e\u043c \u043a\u0430\u043a \u0442\u043e\u0447\u043a\u0443 \u0434\u043b\u044f \u043f\u0440\u0438\u0446\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>  \u041c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u0438\u0442\u044c \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440 \u043a \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u043c\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u0432\u0440\u0430\u0433\u0430, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u043f\u043e\u0437\u0438\u0446\u0438\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442 \u0431\u0430\u0448\u043d\u044e \u0446\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0432 \u0437\u0435\u043c\u043b\u044e. \u0422\u043e \u0435\u0441\u0442\u044c \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440 \u0433\u0434\u0435-\u0442\u043e \u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u0438. \u0424\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0434\u0432\u0438\u0436\u043e\u043a \u0434\u0430\u0441\u0442 \u043d\u0430\u043c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043f\u0440\u0438\u0446\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f, \u043d\u043e \u043d\u0430\u043c \u0435\u0449\u0451 \u043d\u0443\u0436\u0435\u043d \u0431\u0443\u0434\u0435\u0442 \u0438 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0443 <code>Enemy<\/code> \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u0427\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 <code>TargetPoint<\/code>. \u0414\u0430\u0434\u0438\u043c \u0435\u043c\u0443 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u043e\u0433\u043e \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0438 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 <code>Enemy<\/code>, \u0438 \u0435\u0449\u0451 \u043e\u0434\u043d\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0435\u0433\u043e \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0432 \u043c\u0438\u0440\u0435.<\/p>\n<pre><code class=\"cs\">using UnityEngine;  public class TargetPoint : MonoBehaviour {  \tpublic Enemy Enemy\u20ac { get; private set; }  \tpublic Vector3 Position =&gt; transform.position; }<\/code><\/pre>\n<p>  \u0414\u0430\u0434\u0438\u043c \u0435\u043c\u0443 \u043c\u0435\u0442\u043e\u0434 <code>Awake<\/code>, \u0437\u0430\u0434\u0430\u044e\u0449\u0438\u0439 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0435\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 <code>Enemy<\/code>. \u041f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u043c\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <code>transform.root<\/code>. \u0415\u0441\u043b\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 <code>Enemy<\/code> \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0442\u043e \u0442\u043e\u0433\u0434\u0430 \u043c\u044b \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0443 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0432\u0440\u0430\u0433\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435.<\/p>\n<pre><code class=\"cs\">\tvoid Awake () { \t\tEnemy\u20ac = transform.root.GetComponent&lt;Enemy&gt;(); \t\tDebug.Assert(Enemy\u20ac != null, \"Target point without Enemy root!\", this); \t}<\/code><\/pre>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u0451\u043d \u043a \u0442\u043e\u043c\u0443 \u0436\u0435 \u0438\u0433\u0440\u043e\u0432\u043e\u043c\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0443, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u0451\u043d <code>TargetPoint<\/code>.<\/p>\n<pre><code class=\"cs\">\t\tDebug.Assert(Enemy\u20ac != null, \"Target point without Enemy root!\", this); \t\tDebug.Assert( \t\t\tGetComponent&lt;SphereCollider&gt;() != null, \t\t\t\"Target point without sphere collider!\", this \t\t);<\/code><\/pre>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043a \u043a\u0443\u0431\u0443 \u043f\u0440\u0435\u0444\u0430\u0431\u0430 \u0432\u0440\u0430\u0433\u0430 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0438 \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440. \u042d\u0442\u043e \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442 \u0431\u0430\u0448\u043d\u0438 \u0446\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0432 \u0446\u0435\u043d\u0442\u0440 \u043a\u0443\u0431\u0430. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0444\u0435\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440 \u0441 \u0440\u0430\u0434\u0438\u0443\u0441\u043e\u043c 0.25. \u041a\u0443\u0431 \u0438\u043c\u0435\u0435\u0442 \u043c\u0430\u0441\u0448\u0442\u0430\u0431 0.5, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0441\u0442\u0438\u043d\u043d\u044b\u0439 \u0440\u0430\u0434\u0438\u0443\u0441 \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u0435\u043d 0.125. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u0432\u0440\u0430\u0433 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u044c \u043a\u0440\u0443\u0433 \u0434\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0431\u0430\u0448\u043d\u0438, \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043f\u0443\u0441\u0442\u044f \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0439 \u0446\u0435\u043b\u044c. \u041d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440\u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u043b\u0438\u044f\u0435\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u043c\u0430\u0441\u0448\u0442\u0430\u0431 \u0432\u0440\u0430\u0433\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u0432 \u0438\u0433\u0440\u0435 \u0442\u043e\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u0430\u0440\u044c\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f.<\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/85e\/5ca\/5e4\/85e5ca5e47b8d59fa4211c78126bd512.png\" width=\"176\" height=\"176\"><\/div>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/7ae\/a71\/aec\/7aea71aecbd64d4e045df141ecd1c711.png\" width=\"320\" height=\"176\" alt=\"inspector\"><\/div>\n<p>  <i>\u0412\u0440\u0430\u0433 \u0441 \u0442\u043e\u0447\u043a\u043e\u0439 \u0434\u043b\u044f \u043f\u0440\u0438\u0446\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f \u0438 \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440\u043e\u043c \u043d\u0430 \u043a\u0443\u0431\u0435.<\/i><\/p>\n<h3>\u0421\u043b\u043e\u0439 \u0432\u0440\u0430\u0433\u043e\u0432<\/h3>\n<p>  \u0411\u0430\u0448\u043d\u0438 \u0432\u043e\u043b\u043d\u0443\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0440\u0430\u0433\u0438, \u0438 \u043e\u043d\u0438 \u043d\u0435 \u0446\u0435\u043b\u044f\u0442\u0441\u044f \u043d\u0438 \u0432\u043e \u0447\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043c \u0432\u0441\u0435\u0445 \u0432\u0440\u0430\u0433\u043e\u0432 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u043b\u043e\u0439. \u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0441\u043b\u043e\u0435\u043c 9. \u0418\u0437\u043c\u0435\u043d\u0438\u0442\u0435 \u0435\u0433\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 <em>Enemy<\/em> \u0432 \u043e\u043a\u043d\u0435 <em>Layers &amp; Tags<\/em>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043e\u043f\u0446\u0438\u044e <em>Edit Layers<\/em> \u0432 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0435\u043c\u0441\u044f \u043c\u0435\u043d\u044e <em>Layers<\/em> \u0432 \u043f\u0440\u0430\u0432\u043e\u043c \u0432\u0435\u0440\u0445\u043d\u0435\u043c \u0443\u0433\u043b\u0443 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430.<\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8e6\/9a5\/762\/8e69a5762e8eb1856175f9d9dc1ab388.png\" width=\"320\" height=\"308\"><\/div>\n<p>  <i>\u0421\u043b\u043e\u0439 9 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0432\u0440\u0430\u0433\u043e\u0432.<\/i><\/p>\n<p>  \u042d\u0442\u043e\u0442 \u0441\u043b\u043e\u0439 \u043d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0432\u0440\u0430\u0433\u043e\u0432, \u0430 \u043d\u0435 \u0434\u043b\u044f \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0443\u043a\u0430\u0436\u0435\u043c \u043d\u0430 \u044d\u0442\u043e, \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0432 \u0438\u0445 \u0432 <em>Layer Collision Matrix<\/em>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043f\u0430\u043d\u0435\u043b\u0438 <em>Physics<\/em> \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/876\/06e\/e7d\/87606ee7dfc4777760d81219517125ce.png\" width=\"200\" height=\"200\"><\/div>\n<p>  <i>\u041c\u0430\u0442\u0440\u0438\u0446\u0430 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0439 \u0441\u043b\u043e\u0451\u0432.<\/i><\/p>\n<p>  \u0423\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u0438\u0433\u0440\u043e\u0432\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0442\u043e\u0447\u043a\u0438 \u043f\u0440\u0438\u0446\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u043d\u0443\u0436\u043d\u043e\u043c \u0441\u043b\u043e\u0435. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u0435\u0444\u0430\u0431\u0430 \u0432\u0440\u0430\u0433\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u043b\u043e\u044f\u0445, \u043d\u043e \u043f\u0440\u043e\u0449\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u0441\u0451 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u0442\u044c \u0438 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432\u0435\u0441\u044c \u043f\u0440\u0435\u0444\u0430\u0431 \u0432 \u0441\u043b\u043e\u0439 <em>Enemy<\/em>. \u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0435 \u0441\u043b\u043e\u0439 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0442\u043e \u0432\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u043b\u043e\u0439 \u0438 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0435\u0433\u043e \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432.<\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6d1\/f75\/062\/6d1f75062420abadb285e9efca1e1a5e.png\" width=\"320\" height=\"44\"><\/div>\n<p>  <i>\u0412\u0440\u0430\u0433 \u043d\u0430 \u043d\u0443\u0436\u043d\u043e\u043c \u0441\u043b\u043e\u0435.<\/i><\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e <code>TargetPoint<\/code> \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u043d\u0443\u0436\u043d\u043e\u043c \u0441\u043b\u043e\u0435.<\/p>\n<pre><code class=\"cs\">\tvoid Awake () { \t\t\u2026 \t\tDebug.Assert(gameObject.layer == 9, \"Target point on wrong layer!\", this); \t}<\/code><\/pre>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0438\u0433\u0440\u043e\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0440\u0430\u0436\u0435\u0441\u043a\u0438\u0435 \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440\u044b. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043c\u0430\u0441\u043a\u0438 \u0441\u043b\u043e\u044f \u043a <code>Physics.Raycast<\/code> \u0432 <code>GameBoard.GetTile<\/code>. \u0423 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0435\u0441\u0442\u044c \u0444\u043e\u0440\u043c\u0430, \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0449\u0430\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0434\u043e \u043b\u0443\u0447\u0430 \u0438 \u043c\u0430\u0441\u043a\u0443 \u0441\u043b\u043e\u044f. \u041f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u0435\u043c\u0443 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438 \u043c\u0430\u0441\u043a\u0443 \u0441\u043b\u043e\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0442\u043e \u0435\u0441\u0442\u044c 1.<\/p>\n<pre><code class=\"cs\">\tpublic GameTile GetTile (Ray ray) { \t\tif (Physics.Raycast(ray, out RaycastHit hit, float.MaxValue, 1)) { \t\t\t\u2026 \t\t} \t\treturn null; \t}<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0430\u0437\u0432\u0435 \u043c\u0430\u0441\u043a\u0430 \u0441\u043b\u043e\u044f \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u0440\u0430\u0432\u043d\u044f\u0442\u044c\u0441\u044f 0?<\/b><\/p>\n<div class=\"spoiler_text\">\u0418\u043d\u0434\u0435\u043a\u0441 \u0441\u043b\u043e\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0440\u0430\u0432\u0435\u043d \u043d\u0443\u043b\u044e, \u043d\u043e \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u043c\u0430\u0441\u043a\u0443 \u0441\u043b\u043e\u044f. \u041c\u0430\u0441\u043a\u0430 \u043c\u0435\u043d\u044f\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0431\u0438\u0442\u044b \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u043d\u0430 1, \u0435\u0441\u043b\u0438 \u0441\u043b\u043e\u0439 \u043d\u0443\u0436\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u0431\u0438\u0442, \u0442\u043e \u0435\u0441\u0442\u044c \u0441\u0430\u043c\u044b\u0439 \u043c\u043b\u0430\u0434\u0448\u0438\u0439, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442, 2<sup>0<\/sup>, \u0447\u0442\u043e \u0440\u0430\u0432\u043d\u044f\u0435\u0442\u0441\u044f 1.<\/div>\n<\/div>\n<p>  <\/p>\n<h3>\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u0442\u0430\u0439\u043b\u043e\u0432<\/h3>\n<p>  \u0411\u0430\u0448\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0441\u0432\u043e\u044e \u0437\u0430\u0434\u0430\u0447\u0443, \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u0438\u0445 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f. \u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u0438 \u043a \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u043c\u0443 \u0442\u0430\u0439\u043b\u043e\u0432 \u0446\u0435\u043b\u043e\u043c, \u0445\u043e\u0442\u044c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043f\u043e\u043a\u0430 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 <code>GameTileContent<\/code> \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <code>GameUpdate<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442.<\/p>\n<pre><code class=\"cs\">\tpublic virtual void GameUpdate () {}<\/code><\/pre>\n<p>  \u0417\u0430\u0441\u0442\u0430\u0432\u0438\u043c <code>Tower<\/code> \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0435\u0433\u043e, \u043f\u0443\u0441\u0442\u044c \u043f\u043e\u043a\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c, \u0447\u0442\u043e \u0438\u0449\u0435\u0442 \u0446\u0435\u043b\u044c.<\/p>\n<pre><code class=\"cs\">\tpublic override void GameUpdate () { \t\tDebug.Log(\"Searching for target...\"); \t}<\/code><\/pre>\n<p>  <code>GameBoard<\/code> \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u0439\u043b\u0430\u043c\u0438 \u0438 \u0438\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c, \u043a\u0430\u043a\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u043c\u0443 \u0441\u043f\u0438\u0441\u043e\u043a \u0438 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <code>GameUpdate<\/code>, \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0432\u0441\u0451 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435.<\/p>\n<pre><code class=\"cs\">\tList&lt;GameTileContent&gt; updatingContent = new List&lt;GameTileContent&gt;(); \t \t\u2026 \t \tpublic void GameUpdate () { \t\tfor (int i = 0; i &lt; updatingContent.Count; i++) { \t\t\tupdatingContent[i].GameUpdate(); \t\t} \t}<\/code><\/pre>\n<p>  \u0412 \u043d\u0430\u0448\u0435\u043c \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u043d\u0443\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0430\u0448\u043d\u0438. \u0418\u0437\u043c\u0435\u043d\u0438\u043c <code>ToggleTower<\/code> \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u043b \u0438 \u0443\u0434\u0430\u043b\u044f\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435. \u0415\u0441\u043b\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438 \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u043c\u0443, \u0442\u043e \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043e\u0431\u0449\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u043d\u043e \u043f\u043e\u043a\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0438 \u044d\u0442\u043e\u0433\u043e.<\/p>\n<pre><code class=\"cs\">\tpublic void ToggleTower (GameTile tile) { \t\tif (tile.Content.Type == GameTileContentType.Tower) { \t\t\tupdatingContent.Remove(tile.Content); \t\t\ttile.Content = contentFactory.Get(GameTileContentType.Empty); \t\t\tFindPaths(); \t\t} \t\telse if (tile.Content.Type == GameTileContentType.Empty) { \t\t\ttile.Content = contentFactory.Get(GameTileContentType.Tower); \t\t\t\/\/if (!FindPaths()) { \t\t\tif (FindPaths()) { \t\t\t\tupdatingContent.Add(tile.Content); \t\t\t} \t\t\telse { \t\t\t\ttile.Content = contentFactory.Get(GameTileContentType.Empty); \t\t\t\tFindPaths(); \t\t\t} \t\t} \t\telse if (tile.Content.Type == GameTileContentType.Wall) { \t\t\ttile.Content = contentFactory.Get(GameTileContentType.Tower); \t\t\tupdatingContent.Add(tile.Content); \t\t} \t}<\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e, \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0430\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u043b\u0435 \u0432 <code>Game.Update<\/code>. \u041f\u043e\u043b\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u0441\u043b\u0435 \u0432\u0440\u0430\u0433\u043e\u0432. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u0431\u0430\u0448\u043d\u0438 \u0441\u043c\u043e\u0433\u0443\u0442 \u0446\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0442\u043e\u0447\u043d\u043e \u0442\u0443\u0434\u0430, \u0433\u0434\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432\u0440\u0430\u0433\u0438. \u0415\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0438\u043d\u0430\u0447\u0435, \u0442\u043e \u0431\u0430\u0448\u043d\u0438 \u0431\u044b \u0446\u0435\u043b\u0438\u043b\u0438\u0441\u044c \u0442\u0443\u0434\u0430, \u0433\u0434\u0435 \u0431\u044b\u043b\u0438 \u0432\u0440\u0430\u0433\u0438 \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u043c \u043a\u0430\u0434\u0440\u0435.<\/p>\n<pre><code class=\"cs\">\tvoid Update () { \t\t\u2026 \t\tenemies.GameUpdate(); \t\tboard.GameUpdate(); \t}<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0414\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u0446\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f<\/h3>\n<p>  \u0423 \u0431\u0430\u0448\u0435\u043d \u0435\u0441\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u0439 \u0440\u0430\u0434\u0438\u0443\u0441 \u043f\u0440\u0438\u0446\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f. \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0435\u0433\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c\u044b\u043c, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u043f\u043e\u043b\u0435 \u0432 \u043a\u043b\u0430\u0441\u0441 <code>Tower<\/code>. \u0420\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043e\u0442 \u0446\u0435\u043d\u0442\u0440\u0430 \u0442\u0430\u0439\u043b\u0430 \u0431\u0430\u0448\u043d\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438 \u0434\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 0.5 \u043e\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0442\u0430\u0439\u043b. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u0443\u043c\u043d\u044b\u043c \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u043e\u043c \u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0434\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e \u0431\u0443\u0434\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 1.5, \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0435\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u0442\u0430\u0439\u043b\u043e\u0432.<\/p>\n<pre><code class=\"cs\">\t[SerializeField, Range(1.5f, 10.5f)] \tfloat targetingRange = 1.5f;<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c38\/ae4\/ee8\/c38ae4ee885cf5d89f24164b9c6bc5fe.png\" width=\"320\" height=\"74\"><\/div>\n<p>  <i>\u0414\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u0446\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f 2.5.<\/i><\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0434\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0433\u0438\u0437\u043c\u043e. \u041d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c \u0435\u0451 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u0435\u0442\u043e\u0434 <code>OnDrawGizmosSelected<\/code>, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u041e\u0442\u0440\u0438\u0441\u0443\u0435\u043c \u0436\u0451\u043b\u0442\u044b\u0439 \u043a\u0430\u0440\u043a\u0430\u0441 \u0441\u0444\u0435\u0440\u044b \u0441 \u0440\u0430\u0434\u0438\u0443\u0441\u043e\u043c, \u0440\u0430\u0432\u043d\u044b\u043c \u0434\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u0446\u0435\u043d\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u0430\u0448\u043d\u0438. \u0420\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0438\u043c \u0435\u0433\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0448\u0435 \u0437\u0435\u043c\u043b\u0438, \u0447\u0442\u043e\u0431\u044b \u0435\u0433\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u044b\u043b\u043e \u0447\u0451\u0442\u043a\u043e \u0432\u0438\u0434\u043d\u043e.<\/p>\n<pre><code class=\"cs\">\tvoid OnDrawGizmosSelected () { \t\tGizmos.color = Color.yellow; \t\tVector3 position = transform.localPosition; \t\tposition.y += 0.01f; \t\tGizmos.DrawWireSphere(position, targetingRange); \t}<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/674\/6b7\/3cd\/6746b73cd2e015fd599b770bb89e1c8a.png\" width=\"230\" height=\"230\"><\/div>\n<p>  <i>\u0413\u0438\u0437\u043c\u043e \u0434\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u0446\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f.<\/i><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u0438\u0434\u0435\u0442\u044c, \u043a\u0442\u043e \u0438\u0437 \u0432\u0440\u0430\u0433\u043e\u0432 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0439 \u0446\u0435\u043b\u044c\u044e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u0431\u0430\u0448\u0435\u043d. \u041d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0431\u0430\u0448\u043d\u0438 \u0432 \u043e\u043a\u043d\u0435 \u0441\u0446\u0435\u043d\u044b \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u0437 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u043a\u0443\u0431\u043e\u0432, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0431\u0430\u0448\u043d\u0438. \u0414\u0440\u0443\u0433\u0438\u0435 \u0442\u0438\u043f\u044b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u0442\u0430\u0439\u043b\u043e\u0432 \u0442\u043e\u0436\u0435 \u0441\u0442\u0440\u0430\u0434\u0430\u044e\u0442 \u043e\u0442 \u0442\u043e\u0439 \u0436\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0432 \u043e\u043a\u043d\u0435 \u0441\u0446\u0435\u043d\u044b \u043a\u043e\u0440\u0435\u043d\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f \u0442\u0430\u0439\u043b\u0430, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0432 <code>GameTileContent<\/code> \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>SelectionBase<\/code>.<\/p>\n<pre><code class=\"cs\">[SelectionBase] public class GameTileContent : MonoBehaviour { \u2026 }<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0417\u0430\u0445\u0432\u0430\u0442 \u0446\u0435\u043b\u0438<\/h3>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043b\u0430\u0441\u0441\u0443 <code>Tower<\/code> \u043f\u043e\u043b\u0435 <code>TargetPoint<\/code>, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043c\u043e\u0433 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0437\u0430\u0445\u0432\u0430\u0447\u0435\u043d\u043d\u0443\u044e \u0446\u0435\u043b\u044c. \u0417\u0430\u0442\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0438\u043c <code>GameUpdate<\/code>, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0432\u044b\u0437\u044b\u0432\u0430\u043b \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <code>AquireTarget<\/code>, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u043e\u043c, \u043d\u0430\u0448\u0451\u043b \u043b\u0438 \u043e\u043d \u0446\u0435\u043b\u044c. \u041f\u0440\u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0438 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c.<\/p>\n<pre><code class=\"cs\">\tTargetPoint target;  \tpublic override void GameUpdate () { \t\tif (AcquireTarget()) { \t\t\tDebug.Log(\"Acquired target!\"); \t\t} \t}<\/code><\/pre>\n<p>  \u0412 <code>AcquireTarget<\/code> \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432\u0441\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0446\u0435\u043b\u0438, \u0432\u044b\u0437\u0432\u0430\u0432 <code>Physics.OverlapSphere<\/code> \u0441 \u043f\u043e\u0437\u0438\u0446\u0438\u0435\u0439 \u0431\u0430\u0448\u043d\u0438 \u0438 \u0434\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 <code>Collider<\/code>, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0432\u0441\u0435 \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440\u044b, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0435\u0441\u044f \u0432 \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u0435 \u0441\u043e \u0441\u0444\u0435\u0440\u043e\u0439. \u0415\u0441\u043b\u0438 \u0434\u043b\u0438\u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u0430, \u0442\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u043d\u0430 \u0442\u043e\u0447\u043a\u0430 \u043f\u0440\u0438\u0446\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f, \u0438 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u0435\u0440\u0432\u0443\u044e. \u0412\u043e\u0437\u044c\u043c\u0451\u043c \u0435\u0451 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 <code>TargetPoint<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c, \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u043c \u0435\u0433\u043e \u043f\u043e\u043b\u044e target \u0438 \u0441\u043e\u043e\u0431\u0449\u0438\u043c \u043e\u0431 \u0443\u0441\u043f\u0435\u0445\u0435. \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0447\u0438\u0441\u0442\u0438\u043c target \u0438 \u0441\u043e\u043e\u0431\u0449\u0438\u043c \u043e \u043d\u0435\u0443\u0434\u0430\u0447\u0435.<\/p>\n<pre><code class=\"cs\">\tbool AcquireTarget () { \t\tCollider[] targets = Physics.OverlapSphere( \t\t\ttransform.localPosition, targetingRange \t\t); \t\tif (targets.Length &gt; 0) { \t\t\ttarget = targets[0].GetComponent&lt;TargetPoint&gt;(); \t\t\tDebug.Assert(target != null, \"Targeted non-enemy!\", targets[0]); \t\t\treturn true; \t\t} \t\ttarget = null; \t\treturn false; \t}<\/code><\/pre>\n<p>  \u041c\u044b \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 \u043f\u0440\u0438\u0446\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u0431\u0443\u0434\u0435\u043c \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0441\u043b\u043e\u0435 \u0432\u0440\u0430\u0433\u043e\u0432. \u042d\u0442\u043e \u0441\u043b\u043e\u0439 9, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u043c\u0430\u0441\u043a\u0443 \u0441\u043b\u043e\u044f.<\/p>\n<pre><code class=\"cs\">\tconst int enemyLayerMask = 1 &lt;&lt; 9;  \t\u2026  \tbool AcquireTarget () { \t\tCollider[] targets = Physics.OverlapSphere( \t\t\ttransform.localPosition, targetingRange, enemyLayerMask \t\t); \t\t\u2026 \t}<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u044d\u0442\u0430 \u0431\u0438\u0442\u043e\u0432\u0430\u044f \u043c\u0430\u0441\u043a\u0430?<\/b><\/p>\n<div class=\"spoiler_text\">\u0422\u0430\u043a \u043a\u0430\u043a \u0441\u043b\u043e\u0439 \u0432\u0440\u0430\u0433\u043e\u0432 \u0438\u043c\u0435\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 9, \u0434\u0435\u0441\u044f\u0442\u044b\u0439 \u0431\u0438\u0442 \u0431\u0438\u0442\u043e\u0432\u043e\u0439 \u043c\u0430\u0441\u043a\u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 1. \u042d\u0442\u043e\u043c\u0443 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e 2<sup>9<\/sup>, \u0442\u043e \u0435\u0441\u0442\u044c 512. \u041d\u043e \u0442\u0430\u043a\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0431\u0438\u0442\u043e\u0432\u043e\u0439 \u043c\u0430\u0441\u043a\u0438 \u043d\u0435\u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u0430. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0432\u043e\u0438\u0447\u043d\u044b\u0439 \u043b\u0438\u0442\u0435\u0440\u0430\u043b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <code>0b10_0000_0000<\/code>, \u043d\u043e \u0442\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0443\u043b\u0438. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0441\u0434\u0432\u0438\u0433\u0430 \u0432\u043b\u0435\u0432\u043e <code>&lt;&lt;<\/code>, \u0441\u0434\u0432\u0438\u0433\u0430\u044e\u0449\u0435\u0433\u043e \u0431\u0438\u0442\u044b \u0432\u043b\u0435\u0432\u043e. \u0447\u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0447\u0438\u0441\u043b\u0443 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0434\u0432\u043e\u0439\u043a\u0438.<\/div>\n<\/div>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u0445\u0432\u0430\u0447\u0435\u043d\u043d\u0443\u044e \u0446\u0435\u043b\u044c, \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u0430\u0432 \u043b\u0438\u043d\u0438\u044e-\u0433\u0438\u0437\u043c\u043e \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u0437\u0438\u0446\u0438\u044f\u043c\u0438 \u0431\u0430\u0448\u043d\u0438 \u0438 \u0446\u0435\u043b\u0438.<\/p>\n<pre><code class=\"cs\">\tvoid OnDrawGizmosSelected () { \t\t\u2026 \t\tif (target != null) { \t\t\tGizmos.DrawLine(position, target.Position); \t\t} \t}<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/7a5\/e99\/4be\/7a5e994be6b7d848c2d4bfe7d627c708.png\" width=\"230\" height=\"230\"><\/div>\n<p>  <i>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0446\u0435\u043b\u0435\u0439.<\/i><\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u043d\u0430\u043f\u043e\u0434\u043e\u0431\u0438\u0435 OnTriggerEnter?<\/b><\/p>\n<div class=\"spoiler_text\">\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u0440\u0443\u0447\u043d\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0449\u0438\u0445 \u0441\u0444\u0435\u0440\u0443 \u0446\u0435\u043b\u0435\u0439 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438. \u041d\u0435\u0442 \u043f\u0440\u0438\u0447\u0438\u043d \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0446\u0435\u043b\u0435\u0439, \u0435\u0441\u043b\u0438 \u0443 \u0431\u0430\u0448\u043d\u0438 \u043e\u043d\u0430 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044e \u0432\u0441\u0435\u0445 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0446\u0435\u043b\u0435\u0439 \u0437\u0430 \u0440\u0430\u0437 \u043d\u0430\u043c \u043d\u0435 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0446\u0435\u043b\u0435\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0431\u0430\u0448\u043d\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f.<\/div>\n<\/div>\n<p>  <\/p>\n<h3>\u0424\u0438\u043a\u0441\u0430\u0446\u0438\u044f \u043d\u0430 \u0446\u0435\u043b\u0438<\/h3>\n<p>  \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c\u0430\u044f \u0434\u043b\u044f \u0437\u0430\u0445\u0432\u0430\u0442\u0430 \u0446\u0435\u043b\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043f\u043e\u0440\u044f\u0434\u043a\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438\u0445 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0434\u0432\u0438\u0436\u043e\u043a, \u0442\u043e \u0435\u0441\u0442\u044c \u043f\u043e \u0441\u0443\u0442\u0438 \u043e\u043d \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u0435\u043d. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u0442 \u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0437\u0430\u0445\u0432\u0430\u0447\u0435\u043d\u043d\u0430\u044f \u0446\u0435\u043b\u044c \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0431\u0435\u0437 \u0432\u0441\u044f\u043a\u0438\u0445 \u043f\u0440\u0438\u0447\u0438\u043d. \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0431\u0430\u0448\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0446\u0435\u043b\u044c, \u0435\u0439 \u043b\u043e\u0433\u0438\u0447\u043d\u0435\u0435 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0435\u0451 \u043e\u0434\u043d\u0443, \u0430 \u043d\u0435 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0434\u0440\u0443\u0433\u0443\u044e. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043c\u0435\u0442\u043e\u0434 <code>TrackTarget<\/code>, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u0442\u0430\u043a\u043e\u0435 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u043e\u043c, \u0431\u044b\u043b \u043b\u0438 \u043e\u043d \u0443\u0441\u043f\u0435\u0448\u0435\u043d. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0430\u0442\u044c, \u0437\u0430\u0445\u0432\u0430\u0447\u0435\u043d\u0430 \u043b\u0438 \u0446\u0435\u043b\u044c.<\/p>\n<pre><code class=\"cs\">\tbool TrackTarget () { \t\tif (target == null) { \t\t\treturn false; \t\t} \t\treturn true; \t}<\/code><\/pre>\n<p>  \u0412\u044b\u0437\u043e\u0432\u0435\u043c \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0432 <code>GameUpdate<\/code> \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0435 false \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c <code>AcquireTarget<\/code>. \u0415\u0441\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 \u0432\u0435\u0440\u043d\u0443\u043b true, \u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0446\u0435\u043b\u044c. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0432 \u043e\u0431\u0430 \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 <code>if<\/code> \u0441 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c OR, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u043d\u0434 \u0432\u0435\u0440\u043d\u0451\u0442 <code>true<\/code>, \u0442\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c\u0441\u044f, \u0438 \u0432\u044b\u0437\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d. \u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 AND \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0445\u043e\u0436\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<pre><code class=\"cs\">\tpublic override void GameUpdate () { \t\tif (TrackTarget() || AcquireTarget()) { \t\t\tDebug.Log(\"Locked on target!\"); \t\t} \t}<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8ec\/27c\/0a2\/8ec27c0a2201434cba3725621b68aaa1.png\" width=\"230\" height=\"230\"><\/div>\n<p>  <i>\u041e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u0446\u0435\u043b\u0435\u0439.<\/i><\/p>\n<p>  \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0431\u0430\u0448\u043d\u0438 \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043d\u0430 \u0446\u0435\u043b\u0438, \u043f\u043e\u043a\u0430 \u043e\u043d\u0430 \u043d\u0435 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0435\u0442 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0435\u043d\u0430. \u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0432\u0440\u0430\u0433\u043e\u0432 \u043c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e, \u0442\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0438, \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0441\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438 \u043d\u0430 \u0444\u0438\u0433\u0443\u0440\u044b, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u0432 \u0441\u0435\u0440\u0438\u0438 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u043e\u0432 <a href=\"https:\/\/catlikecoding.com\/unity\/tutorials\/object-management\/\">Object Management<\/a>.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0446\u0435\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u0438 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u0434\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438, <code>TrackTarget<\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0431\u0430\u0448\u043d\u0435\u0439 \u0438 \u0446\u0435\u043b\u044c\u044e. \u0415\u0441\u043b\u0438 \u043e\u043d\u0430 \u043f\u0440\u0435\u0432\u044b\u0441\u0438\u0442 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443 \u0434\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0442\u043e \u0446\u0435\u043b\u044c \u043d\u0443\u0436\u043d\u043e \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c false. \u0414\u043b\u044f \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>Vector3.Distance<\/code>.<\/p>\n<pre><code class=\"cs\">\tbool TrackTarget () { \t\tif (target == null) { \t\t\treturn false; \t\t} \t\tVector3 a = transform.localPosition; \t\tVector3 b = target.Position; \t\tif (Vector3.Distance(a, b) &gt; targetingRange) { \t\t\ttarget = null; \t\t\treturn false; \t\t} \t\treturn true; \t}<\/code><\/pre>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0440\u0430\u0434\u0438\u0443\u0441 \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0431\u0430\u0448\u043d\u044f \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0435\u0440\u044f\u0442\u044c \u0446\u0435\u043b\u044c, \u0437\u0430\u0442\u0435\u043c \u0441\u043d\u043e\u0432\u0430 \u0437\u0430\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u0435\u0451, \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0435\u0451 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043a\u0430\u0434\u0440\u0435, \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u044d\u0442\u043e\u0433\u043e, \u043f\u0440\u0438\u0431\u0430\u0432\u0438\u0432 \u043a \u0434\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0434\u0438\u0443\u0441 \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440\u0430.<\/p>\n<pre><code class=\"cs\">\t\tif (Vector3.Distance(a, b) &gt; targetingRange + 0.125f) { \u2026 }<\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0434\u0430\u0451\u0442 \u043d\u0430\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431 \u0432\u0440\u0430\u0433\u0430 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0451\u043d. \u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0434\u0430\u0451\u043c \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0432\u0440\u0430\u0433\u0443 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u043c\u0430\u0441\u0448\u0442\u0430\u0431, \u043d\u0443\u0436\u043d\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0434\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c \u043c\u0430\u0441\u0448\u0442\u0430\u0431, \u0434\u0430\u043d\u043d\u044b\u0439 <code>Enemy<\/code> \u0438 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430-\u0433\u0435\u0442\u0442\u0435\u0440\u0430.<\/p>\n<pre><code class=\"cs\">\tpublic float Scale { get; private set; }  \t\u2026  \tpublic void Initialize (float scale, float speed, float pathOffset) { \t\tScale = scale; \t\t\u2026 \t}<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0432 <code>Tower.TrackTarget<\/code> \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0443\u044e \u0434\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n<pre><code class=\"cs\">\t\tif (Vector3.Distance(a, b) &gt; targetingRange + 0.125f * target.Enemy\u20ac.Scale) { \u2026 }<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0421\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0444\u0438\u0437\u0438\u043a\u0443<\/h3>\n<p>  \u041f\u043e\u0445\u043e\u0436\u0435, \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u043e, \u043d\u043e \u0431\u0430\u0448\u043d\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0446\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0432 \u0446\u0435\u043d\u0442\u0440 \u043f\u043e\u043b\u044f, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0446\u0435\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432\u043d\u0435 \u043f\u0440\u0435\u0434\u0435\u043b\u043e\u0432 \u0434\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0418\u043c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0446\u0435\u043b\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d\u0438 \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043d\u0430 \u043d\u0438\u0445 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043e\u0434\u0438\u043d \u043a\u0430\u0434\u0440.<\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e91\/0a1\/836\/e910a1836ef729d95ebee121a67c3f2c.png\" width=\"230\" height=\"230\"><\/div>\n<p>  <i>\u041d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u0446\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u0435.<\/i><\/p>\n<p>  \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0434\u0432\u0438\u0436\u043a\u0430 \u043d\u0435\u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u0441 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u0438\u0433\u0440\u044b. \u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u0432\u0441\u0435\u0445 \u0432\u0440\u0430\u0433\u043e\u0432 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0432 \u0442\u043e\u0447\u043a\u0435 \u043d\u0430\u0447\u0430\u043b\u0430 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u043c\u0438\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u0446\u0435\u043d\u0442\u0440\u043e\u043c \u043f\u043e\u043b\u044f. \u0417\u0430\u0442\u0435\u043c \u043c\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c \u0438\u0445 \u0432 \u0442\u043e\u0447\u043a\u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f, \u043d\u043e \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0434\u0432\u0438\u0436\u043e\u043a \u0443\u0437\u043d\u0430\u0451\u0442 \u043e\u0431 \u044d\u0442\u043e\u043c \u043d\u0435 \u0441\u0440\u0430\u0437\u0443.<\/p>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u0443\u044e \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044e, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u0443\u044e \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0432 <code>Physics.autoSyncTransforms<\/code> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>true<\/code>. \u041d\u043e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043e\u043d\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0435\u0435 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0451 \u0432\u043c\u0435\u0441\u0442\u0435 \u0438 \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0431\u0430\u0448\u0435\u043d. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0435\u0451, \u0432\u044b\u0437\u044b\u0432\u0430\u044f <code>Physics.SyncTransforms<\/code> \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438 \u0432\u0440\u0430\u0433\u043e\u0432 \u0438 \u043f\u043e\u043b\u044f \u0432 <code>Game.Update<\/code>.<\/p>\n<pre><code class=\"cs\">\tvoid Update () { \t\t\u2026 \t\tenemies.GameUpdate(); \t\tPhysics.SyncTransforms(); \t\tboard.GameUpdate(); \t}<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0418\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u043c \u0432\u044b\u0441\u043e\u0442\u0443<\/h3>\n<p>  \u041f\u043e \u0441\u0443\u0442\u0438, \u043d\u0430\u0448 \u0438\u0433\u0440\u043e\u0432\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 2D. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043c <code>Tower<\/code> \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u043f\u0440\u0438\u0446\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u0438 \u0438 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0438 \u043e\u043d \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b X \u0438 Z. \u0424\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0434\u0432\u0438\u0436\u043e\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 3D-\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435, \u043d\u043e \u043f\u043e \u0441\u0443\u0442\u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 <code>AcquireTarget<\/code> \u0432 2D: \u0440\u0430\u0441\u0442\u044f\u043d\u0435\u043c \u0441\u0444\u0435\u0440\u0443 \u0432\u0432\u0435\u0440\u0445, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0430 \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u043b\u0430 \u0432\u0441\u0435 \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440\u044b, \u0432\u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0438\u0445 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u043f\u043e \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u0438. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432 \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u0444\u0435\u0440\u044b \u043a\u0430\u043f\u0441\u0443\u043b\u0443, \u0432\u0442\u043e\u0440\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0435\u0434\u0438\u043d\u0438\u0446\u0430\u0445 \u043d\u0430\u0434 \u0437\u0435\u043c\u043b\u0451\u0439 (\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0432 \u0442\u0440\u0451\u0445).<\/p>\n<pre><code class=\"cs\">\tbool AcquireTarget () { \t\tVector3 a = transform.localPosition; \t\tVector3 b = a; \t\tb.y += 3f; \t\tCollider[] targets = Physics.OverlapCapsule( \t\t\ta, b, targetingRange, enemyLayerMask \t\t); \t\t\u2026 \t}<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0430\u0437\u0432\u0435 \u043d\u0435\u043b\u044c\u0437\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0439 2D-\u0434\u0432\u0438\u0436\u043e\u043a?<\/b><\/p>\n<div class=\"spoiler_text\">\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0430\u0448\u0430 \u0438\u0433\u0440\u0430 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0432 \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438 XZ, \u0430 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0439 2D-\u0434\u0432\u0438\u0436\u043e\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438 XY. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0432 \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0432\u0441\u0435\u0439 \u0438\u0433\u0440\u044b, \u0438\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435 2D-\u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0444\u0438\u0437\u0438\u043a\u0438. \u041d\u043e \u043b\u0435\u0433\u0447\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c 3D-\u0444\u0438\u0437\u0438\u043a\u0443.<\/div>\n<\/div>\n<p>  \u041d\u0443\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c <code>TrackTarget<\/code>. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c 2D-\u0432\u0435\u043a\u0442\u043e\u0440\u044b \u0438 <code>Vector2.Distance<\/code>, \u043d\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0434\u0451\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u043c \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u044b \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439, \u044d\u0442\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e. \u0422\u0430\u043a \u043c\u044b \u0438\u0437\u0431\u0430\u0432\u0438\u043c\u0441\u044f \u043e\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u0440\u043d\u044f.<\/p>\n<pre><code class=\"cs\">\tbool TrackTarget () { \t\tif (target == null) { \t\t\treturn false; \t\t} \t\tVector3 a = transform.localPosition; \t\tVector3 b = target.Position; \t\tfloat x = a.x - b.x; \t\tfloat z = a.z - b.z; \t\tfloat r = targetingRange + 0.125f * target.Enemy\u20ac.Scale; \t\tif (x * x + z * z &gt; r * r) { \t\t\ttarget = null; \t\t\treturn false; \t\t} \t\treturn true; \t}<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u044d\u0442\u0438 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f?<\/b><\/p>\n<div class=\"spoiler_text\">\u0412 \u043d\u0438\u0445 \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f 2D-\u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u0435\u043e\u0440\u0435\u043c\u0430 \u041f\u0438\u0444\u0430\u0433\u043e\u0440\u0430, \u043d\u043e \u0431\u0435\u0437 \u0440\u0430\u0441\u0447\u0451\u0442\u0430 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u0440\u043d\u044f. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0432\u0430\u0434\u0440\u0430\u0442 \u0440\u0430\u0434\u0438\u0443\u0441\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u044b \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u044b \u0434\u043b\u0438\u043d. \u042d\u0442\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0434\u043b\u0438\u043d\u0443, \u0430 \u043d\u0435 \u0442\u043e\u0447\u043d\u0443\u044e \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u044c.<\/div>\n<\/div>\n<p>  <\/p>\n<h3>\u0418\u0437\u0431\u0435\u0433\u0430\u0435\u043c \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438<\/h3>\n<p>  \u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f <code>Physics.OverlapCapsule<\/code> \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u043e\u043d \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432. \u042d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c, \u0432\u044b\u0434\u0435\u043b\u0438\u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u044f \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <code>OverlapCapsuleNonAlloc<\/code> \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430. \u0414\u043b\u0438\u043d\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432. \u0412\u0441\u0435 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0446\u0435\u043b\u0438 \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f. \u041c\u044b \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u0445\u0432\u0430\u0442\u0438\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0434\u043b\u0438\u043d\u043e\u0439 1.<\/p>\n<p>  \u0412\u043c\u0435\u0441\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 <code>OverlapCapsuleNonAlloc<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u0435\u0434\u0448\u0438\u0445 \u0441\u0442\u043e\u043b\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0439, \u0432\u043f\u043b\u043e\u0442\u044c \u0434\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u0433\u043e, \u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u043e \u0434\u043b\u0438\u043d\u044b \u043c\u0430\u0441\u0441\u0438\u0432\u0430.<\/p>\n<pre><code class=\"cs\">\tstatic Collider[] targetsBuffer = new Collider[1];  \t\u2026  \tbool AcquireTarget () { \t\tVector3 a = transform.localPosition; \t\tVector3 b = a; \t\tb.y += 2f; \t\tint hits = Physics.OverlapCapsuleNonAlloc( \t\t\ta, b, targetingRange, targetsBuffer, enemyLayerMask \t\t); \t\tif (hits &gt; 0) { \t\t\ttarget = targetsBuffer[0].GetComponent&lt;TargetPoint&gt;(); \t\t\tDebug.Assert(target != null, \"Targeted non-enemy!\", targetsBuffer[0]); \t\t\treturn true; \t\t} \t\ttarget = null; \t\treturn false; \t}<\/code><\/pre>\n<p>  <\/p>\n<h2>\u0421\u0442\u0440\u0435\u043b\u044f\u0435\u043c \u0432\u043e \u0432\u0440\u0430\u0433\u043e\u0432<\/h2>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0430\u044f \u0446\u0435\u043b\u044c, \u043d\u0430\u0441\u0442\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0432 \u043d\u0435\u0451 \u0441\u0442\u0440\u0435\u043b\u044f\u0442\u044c. \u0412 \u0441\u0442\u0440\u0435\u043b\u044c\u0431\u0443 \u0432\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438\u0446\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u0435, \u0432\u044b\u0441\u0442\u0440\u0435\u043b \u043b\u0430\u0437\u0435\u0440\u043e\u043c \u0438 \u043d\u0430\u043d\u0435\u0441\u0435\u043d\u0438\u0435 \u0443\u0440\u043e\u043d\u0430.<\/p>\n<h3>\u041f\u0440\u0438\u0446\u0435\u043b\u0438\u0432\u0430\u0435\u043c\u0441\u044f \u0442\u0443\u0440\u0435\u043b\u044c\u044e<\/h3>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0442\u0443\u0440\u0435\u043b\u044c \u043d\u0430 \u0446\u0435\u043b\u044c, \u043a\u043b\u0430\u0441\u0441\u0443 <code>Tower<\/code> \u043d\u0443\u0436\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 <code>Transform<\/code> \u0442\u0443\u0440\u0435\u043b\u0438. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u0435\u0433\u043e \u0432 \u043f\u0440\u0435\u0444\u0430\u0431\u0435 \u0431\u0430\u0448\u043d\u0438.<\/p>\n<pre><code class=\"cs\">\t[SerializeField] \tTransform turret = default;<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e0f\/3be\/41b\/e0f3be41b0936993268316b8f01e1f67.png\" width=\"320\" height=\"90\"><\/div>\n<p>  <i>\u041f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0451\u043d\u043d\u0430\u044f \u0442\u0443\u0440\u0435\u043b\u044c.<\/i><\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432 <code>GameUpdate<\/code> \u0435\u0441\u0442\u044c \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0430\u044f \u0446\u0435\u043b\u044c, \u0442\u043e \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u0442\u0440\u0435\u043b\u044f\u0442\u044c \u0432 \u043d\u0435\u0451. \u041f\u043e\u043c\u0435\u0441\u0442\u0438\u043c \u043a\u043e\u0434 \u0441\u0442\u0440\u0435\u043b\u044c\u0431\u044b \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434. \u0417\u0430\u0441\u0442\u0430\u0432\u0438\u043c \u0435\u0433\u043e \u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0442\u0443\u0440\u0435\u043b\u044c \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0446\u0435\u043b\u0438, \u0432\u044b\u0437\u044b\u0432\u0430\u044f \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434 <code>Transform.LookAt<\/code> \u0441 \u0442\u043e\u0447\u043a\u043e\u0439 \u043f\u0440\u0438\u0446\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430.<\/p>\n<pre><code class=\"cs\">\tpublic override void GameUpdate () { \t\tif (TrackTarget() || AcquireTarget()) { \t\t\t\/\/Debug.Log(\"Locked on target!\"); \t\t\tShoot(); \t\t} \t}  \tvoid Shoot () { \t\tVector3 point = target.Position; \t\tturret.LookAt(point); \t}<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/00e\/5bb\/e9d\/00e5bbe9d98e739800bf47435ca574af.png\" width=\"230\" height=\"230\"><\/div>\n<p>  <i>\u041f\u0440\u043e\u0441\u0442\u043e \u0446\u0435\u043b\u0438\u043c\u0441\u044f.<\/i><\/p>\n<h3>\u0421\u0442\u0440\u0435\u043b\u044f\u0435\u043c \u043b\u0430\u0437\u0435\u0440\u043e\u043c<\/h3>\n<p>  \u0414\u043b\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043b\u0430\u0437\u0435\u0440\u043d\u043e\u0433\u043e \u043b\u0443\u0447\u0430 \u043a\u043b\u0430\u0441\u0441\u0443 <code>Tower<\/code> \u0442\u043e\u0436\u0435 \u043d\u0443\u0436\u043d\u0430 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043d\u0435\u0433\u043e.<\/p>\n<pre><code class=\"cs\">\t[SerializeField] \tTransform turret = default, laserBeam = default;<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/802\/c9c\/86e\/802c9c86eac24112cb2b4f072fd0f410.png\" width=\"320\" height=\"110\"><\/div>\n<p>  <i>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b\u0438 \u043b\u0430\u0437\u0435\u0440\u043d\u044b\u0439 \u043b\u0443\u0447.<\/i><\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u043a\u0443\u0431 \u0432 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u043b\u0430\u0437\u0435\u0440\u043d\u044b\u0439 \u043b\u0443\u0447, \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0440\u0438 \u0448\u0430\u0433\u0430. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0435\u0433\u043e \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0442\u0443\u0440\u0435\u043b\u0438. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0432 \u0435\u0451 \u043f\u043e\u0432\u043e\u0440\u043e\u0442.<\/p>\n<pre><code class=\"cs\">\tvoid Shoot () { \t\tVector3 point = target.Position; \t\tturret.LookAt(point); \t\tlaserBeam.localRotation = turret.localRotation; \t}<\/code><\/pre>\n<p>  \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u043e\u0442\u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c \u043b\u0430\u0437\u0435\u0440\u043d\u044b\u0439 \u043b\u0443\u0447 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0435\u0433\u043e \u0434\u043b\u0438\u043d\u0430 \u0431\u044b\u043b\u0430 \u0440\u0430\u0432\u043d\u0430 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044e \u043c\u0435\u0436\u0434\u0443 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u043d\u0430\u0447\u0430\u043b\u0430 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0442\u0443\u0440\u0435\u043b\u0438 \u0438 \u0442\u043e\u0447\u043a\u043e\u0439 \u043f\u0440\u0438\u0446\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f. \u041c\u044b \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e \u043f\u043e \u043e\u0441\u0438 Z, \u0442\u043e \u0435\u0441\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0441\u0438, \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0446\u0435\u043b\u0438. \u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043c\u0430\u0441\u0448\u0442\u0430\u0431 \u043f\u043e XY, \u0437\u0430\u043f\u0438\u0448\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043c\u0430\u0441\u0448\u0442\u0430\u0431 \u043f\u0440\u0438 \u043f\u0440\u043e\u0431\u0443\u0436\u0434\u0435\u043d\u0438\u0438 (Awake) \u0442\u0443\u0440\u0435\u043b\u0438.<\/p>\n<pre><code class=\"cs\">\tVector3 laserBeamScale;  \tvoid Awake () { \t\tlaserBeamScale = laserBeam.localScale; \t}  \t\u2026  \tvoid Shoot () { \t\tVector3 point = target.Position; \t\tturret.LookAt(point); \t\tlaserBeam.localRotation = turret.localRotation;  \t\tfloat d = Vector3.Distance(turret.position, point); \t\tlaserBeamScale.z = d; \t\tlaserBeam.localScale = laserBeamScale; \t}<\/code><\/pre>\n<p>  \u0412-\u0442\u0440\u0435\u0442\u044c\u0438\u0445, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0438\u043c \u043b\u0430\u0437\u0435\u0440\u043d\u044b\u0439 \u043b\u0443\u0447 \u043f\u043e\u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435 \u043c\u0435\u0436\u0434\u0443 \u0442\u0443\u0440\u0435\u043b\u044c\u044e \u0438 \u0442\u043e\u0447\u043a\u043e\u0439 \u043f\u0440\u0438\u0446\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f.<\/p>\n<pre><code class=\"cs\">\t\tlaserBeam.localScale = laserBeamScale; \t\tlaserBeam.localPosition = \t\t\tturret.localPosition + 0.5f * d * laserBeam.forward;<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/288\/d96\/438\/288d96438354bd732fd7a3bb84ead491.png\" width=\"230\" height=\"230\"><\/div>\n<p>  <i>\u0421\u0442\u0440\u0435\u043b\u044c\u0431\u0430 \u043b\u0430\u0437\u0435\u0440\u043d\u044b\u043c\u0438 \u043b\u0443\u0447\u0430\u043c\u0438.<\/i><\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0430\u0437\u0432\u0435 \u043d\u0435\u043b\u044c\u0437\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043b\u0430\u0437\u0435\u0440\u043d\u044b\u0439 \u043b\u0443\u0447 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u0442\u0443\u0440\u0435\u043b\u0438?<\/b><\/p>\n<div class=\"spoiler_text\">\u0415\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u044d\u0442\u043e, \u0442\u043e \u043d\u0430\u043c \u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u043e\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u043b\u0430\u0437\u0435\u0440\u043d\u044b\u0439 \u043b\u0443\u0447 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u0438 \u043d\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u0441\u044f \u0431\u044b \u0435\u0433\u043e \u0432\u0435\u043a\u0442\u043e\u0440 forward. \u041e\u0434\u043d\u0430\u043a\u043e \u043d\u0430 \u043d\u0435\u0433\u043e \u0431\u044b \u0432\u043b\u0438\u044f\u043b \u043c\u0430\u0441\u0448\u0442\u0430\u0431 \u0442\u0443\u0440\u0435\u043b\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0433\u043e \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0431\u044b \u043a\u043e\u043c\u043f\u0435\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u041f\u0440\u043e\u0449\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u0445 \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/div>\n<\/div>\n<p>  \u042d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043f\u043e\u043a\u0430 \u0442\u0443\u0440\u0435\u043b\u044c \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u0446\u0435\u043b\u0438. \u041d\u043e \u043a\u043e\u0433\u0434\u0430 \u0446\u0435\u043b\u0438 \u043d\u0435\u0442, \u043b\u0430\u0437\u0435\u0440 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043b\u0430\u0437\u0435\u0440\u0430, \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0432 \u0435\u0433\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0443 \u0432 <code>GameUpdate<\/code> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 0.<\/p>\n<pre><code class=\"cs\">\tpublic override void GameUpdate () { \t\tif (TrackTarget() || AcquireTarget()) { \t\t\tShoot(); \t\t} \t\telse { \t\t\tlaserBeam.localScale = Vector3.zero; \t\t} \t}<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/39b\/8c8\/c23\/39b8c8c239e0936137c646f91a4197de.png\" width=\"230\" height=\"230\"><\/div>\n<p>  <i>\u041f\u0440\u043e\u0441\u0442\u0430\u0438\u0432\u0430\u044e\u0449\u0438\u0435 \u0431\u0430\u0448\u043d\u0438 \u043d\u0435 \u0441\u0442\u0440\u0435\u043b\u044f\u044e\u0442.<\/i><\/p>\n<h3>\u0417\u0434\u043e\u0440\u043e\u0432\u044c\u0435 \u0432\u0440\u0430\u0433\u043e\u0432<\/h3>\n<p>  \u041f\u043e\u043a\u0430 \u043d\u0430\u0448\u0438 \u043b\u0430\u0437\u0435\u0440\u043d\u044b\u0435 \u043b\u0443\u0447\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u0430\u0441\u0430\u044e\u0442\u0441\u044f \u0432\u0440\u0430\u0433\u043e\u0432 \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0438\u043a\u0430\u043a \u043d\u0430 \u043d\u0438\u0445 \u043d\u0435 \u0432\u043b\u0438\u044f\u044e\u0442. \u041d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043b\u0430\u0437\u0435\u0440 \u043d\u0430\u043d\u043e\u0441\u0438\u0442 \u0432\u0440\u0430\u0433\u0430\u043c \u0443\u0440\u043e\u043d. \u041c\u044b \u043d\u0435 \u0445\u043e\u0442\u0438\u043c \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0430\u0442\u044c \u0432\u0440\u0430\u0433\u043e\u0432 \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0434\u0438\u043c <code>Enemy<\/code> \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0437\u0434\u043e\u0440\u043e\u0432\u044c\u044f. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u0434\u043e\u0440\u043e\u0432\u044c\u044f \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043e\u0437\u044c\u043c\u0451\u043c 100. \u041d\u043e \u0431\u0443\u0434\u0435\u0442 \u043b\u043e\u0433\u0438\u0447\u043d\u0435\u0435, \u0447\u0442\u043e\u0431\u044b \u0443 \u043a\u0440\u0443\u043f\u043d\u044b\u0445 \u0432\u0440\u0430\u0433\u043e\u0432 \u0431\u044b\u043b\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0437\u0434\u043e\u0440\u043e\u0432\u044c\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0432\u0435\u0434\u0451\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442.<\/p>\n<pre><code class=\"cs\">\tfloat Health { get; set; } \t \t\u2026  \tpublic void Initialize (float scale, float speed, float pathOffset) { \t\t\u2026 \t\tHealth = 100f * scale; \t}<\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u043d\u0430\u043d\u0435\u0441\u0435\u043d\u0438\u044f \u0443\u0440\u043e\u043d\u0430, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <code>ApplyDamage<\/code>, \u0432\u044b\u0447\u0438\u0442\u0430\u044e\u0449\u0438\u0439 \u0435\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0438\u0437 \u0437\u0434\u043e\u0440\u043e\u0432\u044c\u044f. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c, \u0447\u0442\u043e \u0443\u0440\u043e\u043d \u043d\u0435\u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u0435\u043d, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c.<\/p>\n<pre><code class=\"cs\">\tpublic void ApplyDamage (float damage) { \t\tDebug.Assert(damage &gt;= 0f, \"Negative damage applied.\"); \t\tHealth -= damage; \t}<\/code><\/pre>\n<p>  \u041c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043e\u0442 \u0432\u0440\u0430\u0433\u0430, \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0433\u043e \u0437\u0434\u043e\u0440\u043e\u0432\u044c\u0435 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0435\u0442 \u043d\u0443\u043b\u044f. \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0438\u0441\u0447\u0435\u0440\u043f\u0430\u043d\u0438\u044f \u0437\u0434\u043e\u0440\u043e\u0432\u044c\u044f \u0438 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0435\u043d\u0438\u0435 \u0432\u0440\u0430\u0433\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 <code>GameUpdate<\/code>.<\/p>\n<pre><code class=\"cs\">\tpublic bool GameUpdate () { \t\tif (Health &lt;= 0f) { \t\t\tOriginFactory.Reclaim(this); \t\t\treturn false; \t\t}  \t\t\u2026 \t}<\/code><\/pre>\n<p>  \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u0432\u0441\u0435 \u0431\u0430\u0448\u043d\u0438 \u043f\u043e \u0441\u0443\u0442\u0438 \u0431\u0443\u0434\u0443\u0442 \u0441\u0442\u0440\u0435\u043b\u044f\u0442\u044c \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e, \u0430 \u043d\u0435 \u043f\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0438\u043c \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0435 \u0446\u0435\u043b\u0438, \u0435\u0441\u043b\u0438 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0430\u044f \u0431\u0430\u0448\u043d\u044f \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0438\u043b\u0430 \u0432\u0440\u0430\u0433\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u043d\u0438 \u0442\u043e\u0436\u0435 \u0446\u0435\u043b\u0438\u043b\u0438\u0441\u044c.<\/p>\n<h3>\u0423\u0440\u043e\u043d \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443<\/h3>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0440\u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u043d\u043e\u0441\u0438\u0442\u044c \u043b\u0430\u0437\u0435\u0440. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a <code>Tower<\/code> \u043f\u043e\u043b\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438. \u0422\u0430\u043a \u043a\u0430\u043a \u043b\u0430\u0437\u0435\u0440\u043d\u044b\u0439 \u043b\u0443\u0447 \u043d\u0430\u043d\u043e\u0441\u0438\u0442 \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u044b\u0439 \u0443\u0440\u043e\u043d, \u043c\u044b \u0432\u044b\u0440\u0430\u0437\u0438\u043c \u0435\u0433\u043e \u043a\u0430\u043a \u0443\u0440\u043e\u043d \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 (damage per second). \u0412 <code>Shoot<\/code> \u043f\u0440\u0438\u043b\u043e\u0436\u0438\u043c \u0435\u0433\u043e \u043a \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0443 <code>Enemy<\/code> \u0446\u0435\u043b\u0438 \u0441 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u043d\u0430 \u0434\u0435\u043b\u044c\u0442\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<pre><code class=\"cs\">\t[SerializeField, Range(1f, 100f)] \tfloat damagePerSecond = 10f;  \t\u2026 \t \tvoid Shoot () { \t\t\u2026  \t\ttarget.Enemy.ApplyDamage(damagePerSecond * Time.deltaTime); \t}<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/886\/18f\/199\/88618f199c9c08e7eaeb89b16083f545.png\" width=\"320\" height=\"128\" alt=\"inspector\"><\/div>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/gk\/vt\/sf\/gkvtsfa1ya4igbsjagqhtnzu0wq.gif\"><\/div>\n<p>  <i>\u0423\u0440\u043e\u043d \u043a\u0430\u0436\u0434\u043e\u0439 \u0431\u0430\u0448\u043d\u0438 \u2014 20 \u0435\u0434\u0438\u043d\u0438\u0446 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443.<\/i><\/p>\n<h3>\u041f\u0440\u0438\u0446\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c<\/h3>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u0435\u0440\u0432\u0443\u044e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0443\u044e \u0446\u0435\u043b\u044c, \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0446\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043f\u043e\u0440\u044f\u0434\u043a\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0434\u0432\u0438\u0436\u043e\u043a \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440\u044b. \u042d\u0442\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u0430, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0435\u0439, \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0435\u044e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c, \u043a \u0442\u043e\u043c\u0443 \u0436\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u0440\u0430\u043d\u043d\u043e \u0438 \u043d\u0435\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e. \u0427\u0430\u0441\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0435\u043d\u043d\u043e\u043c\u0443 \u043e\u0433\u043d\u044e, \u043d\u043e \u0442\u0430\u043a \u0431\u044b\u0432\u0430\u0435\u0442 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430.<\/p>\n<p>  \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0434\u0432\u0438\u0436\u043e\u043a, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0441\u0442\u0438. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u044b\u0445 \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440\u0430\u043c\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043e 100. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0446\u0435\u043b\u0435\u0439 \u043d\u0430 \u0433\u0443\u0441\u0442\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u043e\u043c \u0432\u0440\u0430\u0433\u0430\u043c\u0438 \u043f\u043e\u043b\u0435, \u043d\u043e \u044d\u0442\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0446\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f.<\/p>\n<pre><code class=\"cs\">\tstatic Collider[] targetsBuffer = new Collider[100];<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u043c\u0435\u0441\u0442\u043e \u0432\u044b\u0431\u043e\u0440\u0430 \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0446\u0435\u043b\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0438\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<\/p>\n<pre><code class=\"cs\">\tbool AcquireTarget () { \t\t\u2026 \t\tif (hits &gt; 0) { \t\t\ttarget = \t\t\t\ttargetsBuffer[Random.Range(0, hits)].GetComponent&lt;TargetPoint&gt;(); \t\t\t\u2026 \t\t} \t\ttarget = null; \t\treturn false; \t}<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/nv\/lt\/hi\/nvlthij_ixh6lsxgwujtoipjwg4.gif\"><\/div>\n<p>  <i>\u0421\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u043f\u0440\u0438\u0446\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u0435.<\/i><\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0438 \u0432\u044b\u0431\u043e\u0440\u0430 \u0446\u0435\u043b\u0435\u0439?<\/b><\/p>\n<div class=\"spoiler_text\">\u0414\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0446\u0435\u043b\u044c \u0441 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0438\u043b\u0438 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u043c \u0437\u0434\u043e\u0440\u043e\u0432\u044c\u0435\u043c. \u0418\u043b\u0438 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0430\u0448\u0435\u043d \u0446\u0435\u043b\u0438\u0442\u0441\u044f \u0432 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u0440\u0430\u0433\u0430, \u0447\u0442\u043e\u0431\u044b \u0441\u043a\u043e\u043d\u0446\u0435\u043d\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u0440\u0430\u0441\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u0442\u044c \u043e\u0433\u043e\u043d\u044c. \u0418\u043b\u0438 \u0441\u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0435\u0432. \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u043b\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0439 \u043f\u0440\u0438\u0446\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0438 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u043c \u0432\u044b\u0431\u043e\u0440\u0435 \u0446\u0435\u043b\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0431\u0430\u0448\u043d\u0438.<\/div>\n<\/div>\n<p>  \u0418\u0442\u0430\u043a, \u0432 \u043d\u0430\u0448\u0435\u0439 \u0438\u0433\u0440\u0435 \u0436\u0430\u043d\u0440\u0430 \u00ab\u0431\u0430\u0448\u0435\u043d\u043d\u0430\u044f \u0437\u0430\u0449\u0438\u0442\u0430\u00bb \u043d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0431\u0430\u0448\u043d\u0438. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0438\u0433\u0440\u0430 \u0435\u0449\u0451 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0442 \u0441\u0432\u043e\u0438 \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u0447\u0435\u0440\u0442\u0430\u043d\u0438\u044f.<\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/459070\/\"> https:\/\/habr.com\/ru\/post\/459070\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">[<a href=\"https:\/\/habr.com\/ru\/post\/449798\/\">\u041f\u0435\u0440\u0432\u0430\u044f<\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/post\/452756\/\">\u0432\u0442\u043e\u0440\u0430\u044f<\/a> \u0447\u0430\u0441\u0442\u0438 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430]<\/p>\n<ul>\n<li>\u0420\u0430\u0437\u043c\u0435\u0449\u0430\u0435\u043c \u043d\u0430 \u043f\u043e\u043b\u0435 \u0431\u0430\u0448\u043d\u0438.<\/li>\n<li>\u0426\u0435\u043b\u0438\u043c\u0441\u044f \u0432\u043e \u0432\u0440\u0430\u0433\u043e\u0432 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0444\u0438\u0437\u0438\u043a\u0438.<\/li>\n<li>\u041e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u043c \u0438\u0445, \u043f\u043e\u043a\u0430 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e.<\/li>\n<li>\u0421\u0442\u0440\u0435\u043b\u044f\u0435\u043c \u0432 \u043d\u0438\u0445 \u043b\u0430\u0437\u0435\u0440\u043d\u044b\u043c \u043b\u0443\u0447\u043e\u043c.<\/li>\n<\/ul>\n<p>  \u042d\u0442\u043e \u0442\u0440\u0435\u0442\u044c\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u0435\u0440\u0438\u0438 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u043e\u0432 \u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438\u0433\u0440\u044b \u0436\u0430\u043d\u0440\u0430 tower defense. \u0412 \u043d\u0435\u0439 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0431\u0430\u0448\u0435\u043d, \u043f\u0440\u0438\u0446\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u0435 \u0438 \u0441\u0442\u0440\u0435\u043b\u044c\u0431\u0430 \u0432\u043e \u0432\u0440\u0430\u0433\u043e\u0432.<\/p>\n<p>  \u0422\u0443\u0442\u043e\u0440\u0438\u0430\u043b \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0441\u044f \u0432 Unity 2018.3.0f2.<\/p>\n<div style=\"text-align:center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/470\/ceb\/183\/470ceb1832b49ee7372fb79b8425b567.jpg\" width=\"512\" height=\"256\"><\/div>\n<p>  <i>\u0417\u0430\u0434\u0430\u0434\u0438\u043c \u0432\u0440\u0430\u0433\u0430\u043c \u0436\u0430\u0440\u0443.<\/i><\/p>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0431\u0430\u0448\u043d\u0438<\/h2>\n<p>  \u0421\u0442\u0435\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u044e\u0442 \u0432\u0440\u0430\u0433\u043e\u0432, \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u044f \u0434\u043b\u0438\u043d\u0443 \u043f\u0443\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0439\u0442\u0438. \u041d\u043e \u0446\u0435\u043b\u044c \u0438\u0433\u0440\u044b \u2014 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0438\u0442\u044c \u0432\u0440\u0430\u0433\u043e\u0432, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043e\u043d\u0438 \u0434\u043e\u0431\u0435\u0440\u0443\u0442\u0441\u044f \u0434\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438. \u042d\u0442\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0435\u043c \u043d\u0430 \u043f\u043e\u043b\u0435 \u0431\u0430\u0448\u0435\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e \u043d\u0438\u043c \u0441\u0442\u0440\u0435\u043b\u044f\u0442\u044c.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-291941","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/291941","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=291941"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/291941\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=291941"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=291941"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=291941"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}