{"id":291275,"date":"2018-10-24T12:20:02","date_gmt":"2018-10-24T08:20:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=291275"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=291275","title":{"rendered":"\u041a\u0430\u0440\u0442\u044b \u0438\u0437 \u0448\u0435\u0441\u0442\u0438\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432 \u0432 Unity: \u043f\u043e\u0438\u0441\u043a \u043f\u0443\u0442\u0438, \u043e\u0442\u0440\u044f\u0434\u044b \u0438\u0433\u0440\u043e\u043a\u0430, \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\"><a href=\"https:\/\/habr.com\/post\/424257\/\">\u0427\u0430\u0441\u0442\u0438 1-3: \u0441\u0435\u0442\u043a\u0430, \u0446\u0432\u0435\u0442\u0430 \u0438 \u0432\u044b\u0441\u043e\u0442\u044b \u044f\u0447\u0435\u0435\u043a.<\/a><\/p>\n<p>  <a href=\"https:\/\/habr.com\/post\/424491\/\">\u0427\u0430\u0441\u0442\u0438 4-7: \u043d\u0435\u0440\u043e\u0432\u043d\u043e\u0441\u0442\u0438, \u0440\u0435\u043a\u0438 \u0438 \u0434\u043e\u0440\u043e\u0433\u0438.<\/a><\/p>\n<p>  <a href=\"https:\/\/habr.com\/post\/425463\/\">\u0427\u0430\u0441\u0442\u0438 8-11: \u0432\u043e\u0434\u0430, \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0440\u0435\u043b\u044c\u0435\u0444\u0430 \u0438 \u043a\u0440\u0435\u043f\u043e\u0441\u0442\u043d\u044b\u0435 \u0441\u0442\u0435\u043d\u044b<\/a><\/p>\n<p>  <a href=\"https:\/\/habr.com\/post\/425919\/\">\u0427\u0430\u0441\u0442\u0438 12-15: \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430, \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b, \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f<\/a><\/p>\n<h1>\u0427\u0430\u0441\u0442\u044c 16: \u043f\u043e\u0438\u0441\u043a \u043f\u0443\u0442\u0438<\/h1>\n<p>  <\/p>\n<ul>\n<li>\u041f\u043e\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u0435\u043c \u044f\u0447\u0435\u0439\u043a\u0438.<\/li>\n<li>\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0446\u0435\u043b\u0435\u0432\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u043f\u043e\u0438\u0441\u043a\u0430.<\/li>\n<li>\u041d\u0430\u0445\u043e\u0434\u0438\u043c \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0438\u0439 \u043f\u0443\u0442\u044c.<\/li>\n<li>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u043c.<\/li>\n<\/ul>\n<p>  \u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0432 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u044f\u0447\u0435\u0439\u043a\u0430\u043c\u0438, \u043c\u044b \u043f\u0435\u0440\u0435\u0448\u043b\u0438 \u043a \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044e \u043f\u0443\u0442\u0435\u0439 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438.<\/p>\n<p>  \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u044b \u043f\u043e \u043a\u0430\u0440\u0442\u0430\u043c \u0438\u0437 \u0448\u0435\u0441\u0442\u0438\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 Unity 5.6.0. \u041d\u0443\u0436\u043d\u043e \u0443\u0447\u0435\u0441\u0442\u044c, \u0447\u0442\u043e \u0432 5.6 \u0435\u0441\u0442\u044c \u0431\u0430\u0433, \u0440\u0430\u0437\u0440\u0443\u0448\u0430\u044e\u0449\u0438\u0439 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0442\u0435\u043a\u0441\u0442\u0443\u0440 \u0432 \u0441\u0431\u043e\u0440\u043a\u0430\u0445 \u0434\u043b\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c. \u041e\u0431\u043e\u0439\u0442\u0438 \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e, \u0432\u043a\u043b\u044e\u0447\u0438\u0432 \u0432 \u0438\u043d\u0441\u043f\u0435\u043a\u0442\u043e\u0440\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440 <em>Is Readable<\/em>.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/1d9\/165\/c4e\/1d9165c4e1862b050015df3c9dcc48cd.jpg\"><\/div>\n<p>  <i>\u041f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u043c \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u0435.<\/i><br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u041f\u043e\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u044f\u0447\u0435\u0439\u043a\u0438<\/h2>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0438\u0441\u043a\u0430\u0442\u044c \u043f\u0443\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u044f\u0447\u0435\u0439\u043a\u0430\u043c\u0438, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u044d\u0442\u0438 \u044f\u0447\u0435\u0439\u043a\u0438. \u0411\u043e\u043b\u044c\u0448\u0435 \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0431\u043e\u0440 \u043e\u0434\u043d\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438 \u0438 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435 \u0437\u0430 \u043f\u043e\u0438\u0441\u043a\u043e\u043c \u043f\u043e \u043a\u0430\u0440\u0442\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u0432\u044b\u0431\u0435\u0440\u0435\u043c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u043a\u043b\u0435\u0442\u043a\u0443, \u0430 \u043f\u043e\u0442\u043e\u043c \u043a\u043e\u043d\u0435\u0447\u043d\u0443\u044e. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0431\u044b\u043b\u043e \u0431\u044b \u0443\u0434\u043e\u0431\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u0441\u0442\u0430\u043b\u0438 \u043f\u043e\u0434\u0441\u0432\u0435\u0447\u0435\u043d\u043d\u044b\u043c\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0442\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b. \u041f\u043e\u043a\u0430 \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u0438\u043b\u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f, \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0435\u0447\u0442\u043e, \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0449\u0435\u0435 \u043d\u0430\u043c \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435.<\/p>\n<h3>\u0422\u0435\u043a\u0441\u0442\u0443\u0440\u0430-\u043a\u043e\u043d\u0442\u0443\u0440<\/h3>\n<p>  \u041e\u0434\u0438\u043d \u0438\u0437 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u044f\u0447\u0435\u0435\u043a \u2014 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a \u043d\u0438\u043c \u043a\u043e\u043d\u0442\u0443\u0440\u0430. \u041f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0439 \u0448\u0435\u0441\u0442\u0438\u0443\u0433\u043e\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0443\u0440. <a href=\"https:\/\/catlikecoding.com\/unity\/tutorials\/hex-map\/part-16\/highlighting-cells\/cell-outline.png\">\u0417\u0434\u0435\u0441\u044c<\/a> \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443. \u041e\u043d\u0430 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u0430, \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0431\u0435\u043b\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0443\u0440\u0430 \u0448\u0435\u0441\u0442\u0438\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0430. \u0421\u0434\u0435\u043b\u0430\u0432 \u0435\u0451 \u0431\u0435\u043b\u043e\u0439, \u043c\u044b \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0441\u043c\u043e\u0436\u0435\u043c \u0440\u0430\u0441\u043a\u0440\u0430\u0441\u0438\u0442\u044c \u0435\u0451, \u043a\u0430\u043a \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/0j\/4u\/vs\/0j4uvsbyjtxiavcwaajn73csp68.png\"><\/div>\n<p>  <i>\u041a\u043e\u043d\u0442\u0443\u0440 \u044f\u0447\u0435\u0439\u043a\u0438 \u043d\u0430 \u0447\u0451\u0440\u043d\u043e\u043c \u0444\u043e\u043d\u0435.<\/i><\/p>\n<p>  \u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u0438 \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u0434\u043b\u044f \u0435\u0451 <em>Texture Type<\/em> \u0437\u043d\u0430\u0447\u043d\u0435\u0438\u0435 <em>Sprite<\/em>. \u0415\u0451 <em>Sprite Mode<\/em> \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>Single<\/em> \u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u0422\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u0435\u043b\u0430\u044f \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0430, \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 <em>sRGB<\/em>. \u0410\u043b\u044c\u0444\u0430-\u043a\u0430\u043d\u0430\u043b \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043a\u043b\u044e\u0447\u0438\u043c <em>Alpha is Transparency<\/em>. \u0422\u0430\u043a\u0436\u0435 \u044f \u0437\u0430\u0434\u0430\u043b \u0434\u043b\u044f <em>Filter Mode<\/em> \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>Trilinear<\/em>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432 \u0438\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 mip-\u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0443\u0440\u043e\u0432 \u043c\u043e\u0433\u0443\u0442 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0437\u0430\u043c\u0435\u0442\u043d\u044b\u043c\u0438.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/ebb\/e4a\/a88\/ebbe4aa88f93b71cf5946c4c011339dc.png\"><\/div>\n<p>  <i>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b.<\/i><\/p>\n<h3>\u041f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0441\u043f\u0440\u0430\u0439\u0442\u0443 \u043d\u0430 \u044f\u0447\u0435\u0439\u043a\u0443<\/h3>\n<p>  \u0411\u044b\u0441\u0442\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a \u044f\u0447\u0435\u0439\u043a\u0430\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0443\u0440, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u043f\u0440\u0430\u0439\u0442. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u0438\u0433\u0440\u043e\u0432\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a \u043d\u0435\u043c\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 Image (<em>Component \/ UI \/ Image<\/em>) \u0438 \u043d\u0430\u0437\u043d\u0430\u0447\u0438\u043c \u0435\u043c\u0443 \u043d\u0430\u0448 \u0441\u043f\u0440\u0430\u0439\u0442 \u043a\u043e\u043d\u0442\u0443\u0440\u0430. \u0417\u0430\u0442\u0435\u043c \u0432\u0441\u0442\u0430\u0432\u0438\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043f\u0440\u0435\u0444\u0430\u0431\u0430 <em>Hex Cell Label<\/em> \u0432 \u0441\u0446\u0435\u043d\u0443, \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442-\u0441\u043f\u0440\u0430\u0439\u0442 \u0435\u0433\u043e \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043a \u043f\u0440\u0435\u0444\u0430\u0431\u0443, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0438\u0437\u0431\u0430\u0432\u0438\u043c\u0441\u044f \u043e\u0442 \u043f\u0440\u0435\u0444\u0430\u0431\u0430.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5c2\/7f6\/7f4\/5c27f67f4596673f5b2e73b2db5073cd.png\"><\/div>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5da\/f7c\/ea8\/5daf7cea84e2ff46829460e0523bfa91.png\"><\/div>\n<p>  <i>\u0414\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0444\u0430\u0431\u0430.<\/i><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043a\u0430\u0436\u0434\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438 \u0435\u0441\u0442\u044c \u0441\u043f\u0440\u0430\u0439\u0442, \u043d\u043e \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u043c. \u0427\u0442\u043e\u0431\u044b \u043a\u043e\u043d\u0442\u0443\u0440\u044b \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0438 \u0446\u0435\u043d\u0442\u0440\u0430\u043c \u044f\u0447\u0435\u0435\u043a, \u0438\u0437\u043c\u0435\u043d\u0438\u043c <em>Width<\/em> \u0438 <em>Height<\/em> \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 transform \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u043d\u0430 17.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/bc1\/069\/e42\/bc1069e4216435f1a30af953af5b948a.png\"><\/div>\n<p>  <i>\u0421\u043f\u0440\u0430\u0439\u0442\u044b \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f, \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u0441\u043a\u0440\u044b\u0442\u044b\u0435 \u0440\u0435\u043b\u044c\u0435\u0444\u043e\u043c.<\/i><\/p>\n<h3>\u0420\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0432\u0435\u0440\u0445 \u0432\u0441\u0435\u0433\u043e<\/h3>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u043a\u043e\u043d\u0442\u0443\u0440 \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0440\u0451\u0431\u0435\u0440 \u044f\u0447\u0435\u0435\u043a, \u043e\u043d \u0447\u0430\u0441\u0442\u043e \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0434 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0435\u0439 \u0440\u0435\u043b\u044c\u0435\u0444\u0430. \u0418\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u043d\u0442\u0443\u0440\u0430 \u0438\u0441\u0447\u0435\u0437\u0430\u0435\u0442. \u042d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c, \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u043d\u044f\u0432 \u0441\u043f\u0440\u0430\u0439\u0442\u044b \u043f\u043e \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u0438, \u043d\u043e \u043d\u0435 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0431\u0440\u044b\u0432\u043e\u0432. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435: \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0441\u043f\u0440\u0430\u0439\u0442\u044b \u043f\u043e\u0432\u0435\u0440\u0445 \u0432\u0441\u0435\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440. \u041d\u0430\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 Unity \u0438 \u0432\u043d\u0435\u0441\u0442\u0438 \u0432 \u043d\u0435\u0433\u043e \u043f\u0430\u0440\u0443 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.<\/p>\n<pre><code>Shader \"Custom\/Highlight\" { \tProperties { \t\t[PerRendererData] _MainTex (\"Sprite Texture\", 2D) = \"white\" {} \t\t_Color (\"Tint\", Color) = (1,1,1,1) \t\t[MaterialToggle] PixelSnap (\"Pixel snap\", Float) = 0 \t\t[HideInInspector] _RendererColor (\"RendererColor\", Color) = (1,1,1,1) \t\t[HideInInspector] _Flip (\"Flip\", Vector) = (1,1,1,1) \t\t[PerRendererData] _AlphaTex (\"External Alpha\", 2D) = \"white\" {} \t\t[PerRendererData] _EnableExternalAlpha (\"Enable External Alpha\", Float) = 0 \t}  \tSubShader { \t\tTags {  \t\t\t\"Queue\"=\"Transparent\" \t\t\t\"IgnoreProjector\"=\"True\" \t\t\t\"RenderType\"=\"Transparent\" \t\t\t\"PreviewType\"=\"Plane\" \t\t\t\"CanUseSpriteAtlas\"=\"True\" \t\t}  \t\tCull Off \t\tZWrite Off \t\tBlend One OneMinusSrcAlpha  \t\tPass { \t\t\tCGPROGRAM \t\t\t#pragma vertex SpriteVert \t\t\t#pragma fragment SpriteFrag \t\t\t#pragma target 2.0 \t\t\t#pragma multi_compile_instancing \t\t\t#pragma multi_compile _ PIXELSNAP_ON \t\t\t#pragma multi_compile _ ETC1_EXTERNAL_ALPHA \t\t\t#include \"UnitySprites.cginc\" \t\t\tENDCG \t\t} \t} }<\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0432\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u2014 \u043c\u044b \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u043c \u0431\u0443\u0444\u0435\u0440 \u0433\u043b\u0443\u0431\u0438\u043d\u044b, \u0441\u0434\u0435\u043b\u0430\u0432 \u0442\u0430\u043a, \u0447\u0442\u043e Z-\u0442\u0435\u0441\u0442 \u0432\u0441\u0435\u0433\u0434\u0430 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0443\u0434\u0430\u0447\u0435\u0439.<\/p>\n<pre><code>\t\tZWrite Off \t\tZTest Always<\/code><\/pre>\n<p>  \u0412\u0442\u043e\u0440\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u2014 \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0443 \u043f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0439 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0439 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0438. \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0431\u0430\u0432\u0438\u0442\u044c 10 \u043a \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438.<\/p>\n<pre><code>\t\t\t\"Queue\"=\"Transparent+10\"<\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0448\u0435\u0439\u0434\u0435\u0440. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0435\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u043f\u0440\u0438\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044f\u0441\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u0417\u0430\u0442\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u0444\u0430\u0431 \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u044d\u0442\u043e\u0442 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/15b\/d01\/812\/15bd01812d94f52ced67308dd000c430.png\"><\/div>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/ef5\/393\/e24\/ef5393e241252d81513a0ff5f8972b50.png\"><\/div>\n<p>  <i>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u0441\u043f\u0440\u0430\u0439\u0442\u0430.<\/i><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u043d\u0442\u0443\u0440\u044b \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0432\u0438\u0434\u043d\u044b \u0432\u0441\u0435\u0433\u0434\u0430. \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u044f\u0447\u0435\u0439\u043a\u0430 \u0441\u043a\u0440\u044b\u0442\u0430 \u043f\u043e\u0434 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u0438\u043c \u0440\u0435\u043b\u044c\u0435\u0444\u043e\u043c, \u0435\u0451 \u043a\u043e\u043d\u0442\u0443\u0440 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0432\u0435\u0440\u0445 \u0432\u0441\u0435\u0433\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0438 \u043d\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0440\u0430\u0441\u0438\u0432\u043e, \u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043a\u043b\u0435\u0442\u043a\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0443\u0442 \u0432\u0438\u0434\u043d\u044b, \u0447\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0441.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/ce2\/8bc\/418\/ce28bc418dc0ec116cff1bcbaddf0363.png\"><\/div>\n<p>  <i>\u0418\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u043c \u0431\u0443\u0444\u0435\u0440 \u0433\u043b\u0443\u0431\u0438\u043d.<\/i><\/p>\n<h3>\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u043d\u0430\u0434 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c<\/h3>\n<p>  \u041c\u044b \u043d\u0435 \u0445\u043e\u0442\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0431\u044b\u043b\u0438 \u043f\u043e\u0434\u0441\u0432\u0435\u0447\u0435\u043d\u044b \u0432\u0441\u0435 \u044f\u0447\u0435\u0439\u043a\u0438. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043e\u043d\u0438 \u0432\u0441\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043d\u0435 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c\u0438. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e, \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 Image \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u0440\u0435\u0444\u0430\u0431\u0430 <em>Highlight<\/em>.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/82f\/00e\/164\/82f00e164316900fb9d9694030298bcc.png\"><\/div>\n<p>  <i>\u041e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 Image.<\/i><\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u044f\u0447\u0435\u0439\u043a\u0438, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 <code>HexCell<\/code> \u043c\u0435\u0442\u043e\u0434 <code>EnableHighlight<\/code>. \u041e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u0440\u0430\u0442\u044c \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u0432\u043e\u0435\u0433\u043e <code>uiRect<\/code> \u0438 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0435\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 Image. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u043a\u0436\u0435 \u043c\u0435\u0442\u043e\u0434 <code>DisableHighlight<\/code>.<\/p>\n<pre><code class=\"cs\">\tpublic void DisableHighlight () { \t\tImage highlight = uiRect.GetChild(0).GetComponent&lt;Image&gt;(); \t\thighlight.enabled = false; \t} \t \tpublic void EnableHighlight () { \t\tImage highlight = uiRect.GetChild(0).GetComponent&lt;Image&gt;(); \t\thighlight.enabled = true; \t}<\/code><\/pre>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0446\u0432\u0435\u0442, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043f\u0440\u0438\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0435 \u043e\u0442\u0442\u0435\u043d\u043e\u043a.<\/p>\n<pre><code class=\"cs\">\tpublic void EnableHighlight (Color color) { \t\tImage highlight = uiRect.GetChild(0).GetComponent&lt;Image&gt;(); \t\thighlight.color = color; \t\thighlight.enabled = true; \t}<\/code><\/pre>\n<p>  <a href=\"https:\/\/catlikecoding.com\/unity\/tutorials\/hex-map\/part-16\/highlighting-cells\/highlighting-cells.unitypackage\" rel=\"nofollow\">unitypackage<\/a><\/p>\n<h2>\u041d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043f\u0443\u0442\u0438<\/h2>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0434\u0435\u043b\u044f\u0442\u044c \u044f\u0447\u0435\u0439\u043a\u0438, \u043d\u0443\u0436\u043d\u043e \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435 \u0438 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0434\u0432\u0435 \u044f\u0447\u0435\u0439\u043a\u0438, \u0430 \u043f\u043e\u0442\u043e\u043c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u043f\u0443\u0442\u044c. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u044f\u0447\u0435\u0439\u043a\u0438, \u0437\u0430\u0442\u0435\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u043f\u043e\u0438\u0441\u043a \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435\u043c \u043f\u0443\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438, \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u0443\u0442\u044c.<\/p>\n<h3>\u041d\u0430\u0447\u0430\u043b\u043e \u043f\u043e\u0438\u0441\u043a\u0430<\/h3>\n<p>  \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0434\u0432\u0435 \u0440\u0430\u0437\u043d\u044b\u0435 \u043a\u043b\u0435\u0442\u043a\u0438, \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0438 \u043f\u043e\u0438\u0441\u043a\u0430. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0447\u0442\u043e \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438 \u043f\u043e\u0438\u0441\u043a\u0430 \u043d\u0430\u0434\u043e \u0443\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u0449\u0435\u043b\u0447\u043a\u0435 \u043c\u044b\u0448\u0438 \u043b\u0435\u0432\u0443\u044e \u043a\u043b\u0430\u0432\u0438\u0448\u0443 Shift. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u044f\u0447\u0435\u0439\u043a\u0430 \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u0438\u0442\u0441\u044f \u0441\u0438\u043d\u0438\u043c \u0446\u0432\u0435\u0442\u043e\u043c. \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u044d\u0442\u0443 \u044f\u0447\u0435\u0439\u043a\u0443 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u043d\u043e\u0432\u043e\u0439 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0440\u043e\u0439 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0442\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 <code>HexMapEditor<\/code> \u043f\u043e\u043b\u0435 <code>searchFromCell<\/code>.<\/p>\n<pre><code class=\"cs\">\tHexCell previousCell, searchFromCell;<\/code><\/pre>\n<p>  \u0412\u043d\u0443\u0442\u0440\u0438 <code>HandleInput<\/code> \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>Input.GetKey(KeyCode.LeftShift)<\/code> \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0437\u0430\u0436\u0430\u0442\u043e\u0439 \u043a\u043b\u0430\u0432\u0438\u0448\u0438 Shift.<\/p>\n<pre><code class=\"cs\">\t\t\tif (editMode) { \t\t\t\tEditCells(currentCell); \t\t\t} \t\t\telse if (Input.GetKey(KeyCode.LeftShift)) { \t\t\t\tif (searchFromCell) { \t\t\t\t\tsearchFromCell.DisableHighlight(); \t\t\t\t} \t\t\t\tsearchFromCell = currentCell; \t\t\t\tsearchFromCell.EnableHighlight(Color.blue); \t\t\t} \t\t\telse { \t\t\t\thexGrid.FindDistancesTo(currentCell); \t\t\t}<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/d50\/a63\/1c3\/d50a631c3f4701e414b2e9a9078a57a2.png\"><\/div>\n<p>  <i>\u041e\u0442\u043a\u0443\u0434\u0430 \u0438\u0441\u043a\u0430\u0442\u044c.<\/i><\/p>\n<h3>\u041a\u043e\u043d\u0435\u0447\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u043f\u043e\u0438\u0441\u043a\u0430<\/h3>\n<p>  \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043a\u0430\u0442\u044c \u0432\u0441\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0434\u043e \u044f\u0447\u0435\u0439\u043a\u0438, \u043c\u044b \u0442\u0435\u043f\u0435\u0440\u044c \u0438\u0449\u0435\u043c \u043f\u0443\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c\u0438 \u044f\u0447\u0435\u0439\u043a\u0430\u043c\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u0443\u0435\u043c <code>HexGrid.FindDistancesTo<\/code> \u0432 <code>HexGrid.FindPath<\/code> \u0438 \u0434\u0430\u0434\u0438\u043c \u0435\u043c\u0443 \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>HexCell<\/code>.\u0422\u0430\u043a\u0436\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043c\u0435\u0442\u043e\u0434 <code>Search<\/code>.<\/p>\n<pre><code class=\"cs\">\tpublic void FindPath (HexCell fromCell, HexCell toCell) { \t\tStopAllCoroutines(); \t\tStartCoroutine(Search(fromCell, toCell)); \t}  \tIEnumerator Search (HexCell fromCell, HexCell toCell) { \t\tfor (int i = 0; i &lt; cells.Length; i++) { \t\t\tcells[i].Distance = int.MaxValue; \t\t}  \t\tWaitForSeconds delay = new WaitForSeconds(1 \/ 60f); \t\tList&lt;HexCell&gt; frontier = new List&lt;HexCell&gt;(); \t\tfromCell.Distance = 0; \t\tfrontier.Add(fromCell); \t\t\u2026 \t}<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c <code>HexMapEditor.HandleInput<\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0451\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 <code>searchFromCell<\/code> \u0438 <code>currentCell<\/code>. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043a\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0437\u043d\u0430\u0435\u043c, \u0438\u0437 \u043a\u0430\u043a\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438 \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043a\u0430\u0442\u044c. \u0418 \u043c\u044b \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u043d\u044b \u0443\u0442\u0440\u0443\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0438\u0441\u043a\u043e\u043c, \u0435\u0441\u043b\u0438 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0430\u044f \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0438 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442.<\/p>\n<pre><code class=\"cs\">\t\t\tif (editMode) { \t\t\t\tEditCells(currentCell); \t\t\t} \t\t\telse if (Input.GetKey(KeyCode.LeftShift)) { \t\t\t\t\u2026 \t\t\t} \t\t\telse if (searchFromCell &amp;&amp; searchFromCell != currentCell) { \t\t\t\thexGrid.FindPath(searchFromCell, currentCell); \t\t\t}<\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u044f \u043a \u043f\u043e\u0438\u0441\u043a\u0443, \u043d\u0430\u043c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0432\u0441\u0435\u0445 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0439. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043c <code>HexGrid.Search<\/code> \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0438 \u0441\u0431\u0440\u043e\u0441\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439. \u0422\u0430\u043a \u043a\u0430\u043a \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0442\u0430\u043a\u0436\u0435 \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0430 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438, \u0437\u0430\u0442\u0435\u043c \u0441\u043d\u043e\u0432\u0430 \u0435\u0451 \u0432\u043a\u043b\u044e\u0447\u0438\u043c. \u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0442\u0430\u043a\u0436\u0435 \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043a\u043e\u043d\u0435\u0447\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0435\u0451 \u043a\u0440\u0430\u0441\u043d\u043e\u0439.<\/p>\n<pre><code class=\"cs\">\tIEnumerator Search (HexCell fromCell, HexCell toCell) { \t\tfor (int i = 0; i &lt; cells.Length; i++) { \t\t\tcells[i].Distance = int.MaxValue; \t\t\tcells[i].DisableHighlight(); \t\t} \t\tfromCell.EnableHighlight(Color.blue); \t\ttoCell.EnableHighlight(Color.red); \t\t \t\t\u2026 \t}<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/181\/01c\/5e5\/18101c5e578322ea99598cbca70f60a9.png\"><\/div>\n<p>  <i>\u041a\u043e\u043d\u0446\u0435\u0432\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438.<\/i><\/p>\n<h3>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u0438\u0441\u043a<\/h3>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043d\u0430\u0448 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432\u0441\u0451 \u0435\u0449\u0451 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0434\u043e \u0432\u0441\u0435\u0445 \u044f\u0447\u0435\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u0441\u0442\u0438\u0436\u0438\u043c\u044b \u0438\u0437 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438. \u041d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u044d\u0442\u043e \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f, \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0439\u0434\u0451\u043c \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0434\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438. \u0422\u043e \u0435\u0441\u0442\u044c \u043a\u043e\u0433\u0434\u0430 \u0442\u0435\u043a\u0443\u0449\u0430\u044f \u044f\u0447\u0435\u0439\u043a\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0439\u0442\u0438 \u0438\u0437 \u0446\u0438\u043a\u043b\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430.<\/p>\n<pre><code class=\"cs\">\t\twhile (frontier.Count &gt; 0) { \t\t\tyield return delay; \t\t\tHexCell current = frontier[0]; \t\t\tfrontier.RemoveAt(0);  \t\t\tif (current == toCell) { \t\t\t\tbreak; \t\t\t}  \t\t\tfor (HexDirection d = HexDirection.NE; d &lt;= HexDirection.NW; d++) { \t\t\t\t\u2026 \t\t\t} \t\t}<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/424\/6e0\/d49\/4246e0d491a1938dfb1e9b3a00080e42.png\"><\/div>\n<p>  <i>\u041e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c\u0441\u044f \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0435.<\/i><\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442, \u0435\u0441\u043b\u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u043d\u0435\u043b\u044c\u0437\u044f \u0434\u043e\u0441\u0442\u0438\u0447\u044c?<\/b><\/p>\n<div class=\"spoiler_text\">\u0422\u043e\u0433\u0434\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442 \u0440\u0430\u0431\u043e\u0442\u0443, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0430\u0439\u0434\u0451\u0442 \u0432\u0441\u0435 \u0434\u043e\u0441\u0442\u0438\u0436\u0438\u043c\u044b\u0435 \u044f\u0447\u0435\u0439\u043a\u0438. \u0411\u0435\u0437 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0435\u0436\u0434\u0435\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0445\u043e\u0434\u0430 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u0430\u043a \u0441\u0442\u0430\u0440\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <code>FindDistancesTo<\/code>.<\/div>\n<\/div>\n<p>  <\/p>\n<h3>\u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043f\u0443\u0442\u0438<\/h3>\n<p>  \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0439\u0442\u0438 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043d\u0430\u0447\u0430\u043b\u043e\u043c \u0438 \u043a\u043e\u043d\u0446\u043e\u043c \u043f\u0443\u0442\u0438, \u043d\u043e \u043f\u043e\u043a\u0430 \u043d\u0435 \u0437\u043d\u0430\u0435\u043c, \u043a\u0430\u043a\u0438\u043c \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u043f\u0443\u0442\u044c. \u0427\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0435\u0433\u043e, \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u0430 \u043a\u0430\u0436\u0434\u0430\u044f \u044f\u0447\u0435\u0439\u043a\u0430. \u041d\u043e \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c?<\/p>\n<p>  \u041f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u044f\u0447\u0435\u0439\u043a\u0438 \u043a \u0433\u0440\u0430\u043d\u0438\u0446\u0435, \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0441\u0435\u0434\u043e\u043c \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u044f\u0447\u0435\u0439\u043a\u0438. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0430\u044f \u044f\u0447\u0435\u0439\u043a\u0430. \u0412\u0441\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u044f\u0447\u0435\u0439\u043a\u0438 \u0431\u044b\u043b\u0438 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u044b \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u044f\u0447\u0435\u0439\u043a\u0443. \u0415\u0441\u043b\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c, \u0438\u0437 \u043a\u0430\u043a\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438 \u0431\u044b\u043b\u0430 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u0430 \u043a\u0430\u0436\u0434\u0430\u044f \u044f\u0447\u0435\u0439\u043a\u0430, \u0442\u043e \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u0435\u0442\u044c \u044f\u0447\u0435\u0435\u043a. \u0415\u0441\u043b\u0438 \u0442\u043e\u0447\u043d\u0435\u0435, \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u0443\u044e \u0441\u0435\u0442\u044c, \u043a\u043e\u0440\u043d\u0435\u043c \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0451 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043f\u0443\u0442\u0438 \u043f\u043e\u0441\u043b\u0435 \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/a71\/331\/153\/a713311534e05f46c6fd22a632100494.png\"><\/div>\n<p>  <i>\u0414\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u0430\u044f \u0441\u0435\u0442\u044c, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0430\u044f \u043f\u0443\u0442\u0438 \u0434\u043e \u0446\u0435\u043d\u0442\u0440\u0430.<\/i><\/p>\n<p>  \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0432 <code>HexCell<\/code> \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0435\u0449\u0451 \u043e\u0434\u043d\u0443 \u044f\u0447\u0435\u0439\u043a\u0443. \u041d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e.<\/p>\n<pre><code class=\"cs\">\tpublic HexCell PathFrom { get; set; }<\/code><\/pre>\n<p>  \u0412 <code>HexGrid.Search<\/code> \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <code>PathFrom<\/code> \u0441\u043e\u0441\u0435\u0434\u0430 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u044f\u0447\u0435\u0439\u043a\u0443 \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0435\u0451 \u043a \u0433\u0440\u0430\u043d\u0438\u0446\u0435. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u044d\u0442\u0443 \u0441\u0441\u044b\u043b\u043a\u0443, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0430\u0439\u0434\u0451\u043c \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u043f\u0443\u0442\u044c \u0434\u043e \u0441\u043e\u0441\u0435\u0434\u0430.<\/p>\n<pre><code class=\"cs\">\t\t\t\tif (neighbor.Distance == int.MaxValue) { \t\t\t\t\tneighbor.Distance = distance; \t\t\t\t\tneighbor.PathFrom = current; \t\t\t\t\tfrontier.Add(neighbor); \t\t\t\t} \t\t\t\telse if (distance &lt; neighbor.Distance) { \t\t\t\t\tneighbor.Distance = distance; \t\t\t\t\tneighbor.PathFrom = current; \t\t\t\t}<\/code><\/pre>\n<p>  \u0414\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0443\u0442\u044c, \u043f\u0440\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0432 \u043f\u043e \u044d\u0442\u0438\u043c \u0441\u0441\u044b\u043b\u043a\u0430\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043a \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0435, \u0438 \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0438\u0445.<\/p>\n<pre><code class=\"cs\">\t\t\tif (current == toCell) { \t\t\t\tcurrent = current.PathFrom; \t\t\t\twhile (current != fromCell) { \t\t\t\t\tcurrent.EnableHighlight(Color.white); \t\t\t\t\tcurrent = current.PathFrom; \t\t\t\t} \t\t\t\tbreak; \t\t\t}<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/f89\/9cc\/8de\/f899cc8de04e0c5666a2a05558b28042.png\"><\/div>\n<p>  <i>\u041f\u0443\u0442\u044c \u043d\u0430\u0439\u0434\u0435\u043d.<\/i><\/p>\n<p>  \u0421\u0442\u043e\u0438\u0442 \u0443\u0447\u0435\u0441\u0442\u044c, \u0447\u0442\u043e \u0447\u0430\u0441\u0442\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0438\u0445 \u043f\u0443\u0442\u0435\u0439. \u041d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u044f\u0447\u0435\u0435\u043a. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0443\u0442\u0438 \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u043e, \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043b\u043e\u0445\u043e, \u043d\u043e \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0433\u043e \u043f\u0443\u0442\u0438 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0431\u044b\u0432\u0430\u0435\u0442. \u041c\u044b \u0432\u0435\u0440\u043d\u0451\u043c\u0441\u044f \u043a \u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0437\u0436\u0435.<\/p>\n<h3>\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0438\u0441\u043a\u0430<\/h3>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u0431\u043e\u0440\u0430 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430. \u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u043d\u043e\u0432\u043e\u0439 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438. \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0441\u0442\u0430\u043b\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, <code>HexMapEditor<\/code> \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c \u043a\u043e\u043d\u0435\u0447\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443.<\/p>\n<pre><code class=\"cs\">\tHexCell previousCell, searchFromCell, searchToCell;<\/code><\/pre>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0442\u0430\u043a\u0436\u0435 \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u043f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430.<\/p>\n<pre><code class=\"cs\">\t\t\telse if (Input.GetKey(KeyCode.LeftShift)) { \t\t\t\tif (searchFromCell) { \t\t\t\t\tsearchFromCell.DisableHighlight(); \t\t\t\t} \t\t\t\tsearchFromCell = currentCell; \t\t\t\tsearchFromCell.EnableHighlight(Color.blue); \t\t\t\tif (searchToCell) { \t\t\t\t\thexGrid.FindPath(searchFromCell, searchToCell); \t\t\t\t} \t\t\t} \t\t\telse if (searchFromCell &amp;&amp; searchFromCell != currentCell) { \t\t\t\tsearchToCell = currentCell; \t\t\t\thexGrid.FindPath(searchFromCell, searchToCell); \t\t\t}<\/code><\/pre>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u0430 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u0435\u043a.<\/p>\n<pre><code class=\"cs\">\t\t\tif (editMode) { \t\t\t\tEditCells(currentCell); \t\t\t} \t\t\telse if ( \t\t\t\tInput.GetKey(KeyCode.LeftShift) &amp;&amp; searchToCell != currentCell \t\t\t) { \t\t\t\t\u2026 \t\t\t}<\/code><\/pre>\n<p>  <a href=\"https:\/\/catlikecoding.com\/unity\/tutorials\/hex-map\/part-16\/finding-a-path\/finding-a-path.unitypackage\" rel=\"nofollow\">unitypackage<\/a><\/p>\n<h2>\u0411\u043e\u043b\u0435\u0435 \u0443\u043c\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a<\/h2>\n<p>  \u0425\u043e\u0442\u044c \u043d\u0430\u0448 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0438\u0439 \u043f\u0443\u0442\u044c, \u043e\u043d \u0442\u0440\u0430\u0442\u0438\u0442 \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u043e\u0447\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u043d\u0435 \u0441\u0442\u0430\u043d\u0443\u0442 \u0447\u0430\u0441\u0442\u044c\u044e \u044d\u0442\u043e\u0433\u043e \u043f\u0443\u0442\u0438. \u041f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435, \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0441. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u043a\u0430\u0440\u0442\u0443 \u00ab\u0441\u0432\u044b\u0441\u043e\u043a\u0430\u00bb, \u043e\u043d \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u043f\u043e\u0438\u0441\u043a \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u0445 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0431\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u044b\u043c. \u041e\u043d \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u0435\u0442 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0434\u043e\u0440\u043e\u0433\u0430\u043c, \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043e\u043d\u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u0443\u044e \u043e\u0442 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0441\u0442\u043e\u0440\u043e\u043d\u0443. \u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u0438\u0441\u043a \u0443\u043c\u043d\u0435\u0435?<\/p>\n<p>  \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u044f\u0447\u0435\u0439\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439, \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043e\u0442 \u044f\u0447\u0435\u0439\u043a\u0438 \u0434\u043e \u043d\u0430\u0447\u0430\u043b\u0430. \u0415\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u0443\u043c\u043d\u0435\u0435, \u0442\u043e \u043d\u0430\u0434\u043e \u0442\u0430\u043a\u0436\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0434\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0435\u0433\u043e \u043c\u044b \u043f\u043e\u043a\u0430 \u043d\u0435 \u0437\u043d\u0430\u0435\u043c. \u041d\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0446\u0435\u043d\u043a\u0443 \u043e\u0441\u0442\u0430\u0432\u0448\u0435\u0433\u043e\u0441\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f. \u041f\u0440\u0438\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043e\u0446\u0435\u043d\u043a\u0438 \u043a \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044e \u0434\u043e \u044f\u0447\u0435\u0439\u043a\u0438 \u0434\u0430\u0451\u0442 \u043d\u0430\u043c \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043e\u0431\u0449\u0435\u0439 \u0434\u043b\u0438\u043d\u044b \u043f\u0443\u0442\u0438, \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0447\u0435\u0440\u0435\u0437 \u044d\u0442\u0443 \u044f\u0447\u0435\u0439\u043a\u0443. \u0417\u0430\u0442\u0435\u043c \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u0432 \u043f\u043e\u0438\u0441\u043a\u0430 \u044f\u0447\u0435\u0435\u043a.<\/p>\n<h3>\u042d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0430 \u043f\u043e\u0438\u0441\u043a\u0430<\/h3>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043e\u0446\u0435\u043d\u043a\u0443 \u0438\u043b\u0438 \u0434\u043e\u0433\u0430\u0434\u043a\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0447\u043d\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u043e \u044d\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u0445 \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a. \u042d\u0442\u0430 \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0443\u044e \u0434\u043e\u0433\u0430\u0434\u043a\u0443 \u043e\u0431 \u043e\u0441\u0442\u0430\u0432\u0448\u0435\u043c\u0441\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0438. \u041c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043f\u043e\u0438\u0441\u043a, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0434\u043b\u044f \u043d\u0435\u0433\u043e <code>HexCell<\/code> \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e. \u041d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0435\u0449\u0451 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430.<\/p>\n<pre><code class=\"cs\">\tpublic int SearchHeuristic { get; set; }<\/code><\/pre>\n<p>  \u041a\u0430\u043a \u043d\u0430\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0441\u0442\u0430\u0432\u0448\u0435\u043c\u0441\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0438? \u0412 \u0441\u0430\u043c\u043e\u043c \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0440\u043e\u0433\u0430, \u0432\u0435\u0434\u0443\u0449\u0430\u044f \u043f\u0440\u044f\u043c\u0438\u043a\u043e\u043c \u043a \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0435. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u0442\u0430\u043a, \u0442\u043e \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0440\u0430\u0432\u043d\u043e \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u0451\u043d\u043d\u043e\u043c\u0443 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044e \u043c\u0435\u0436\u0434\u0443 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c\u0438 \u044d\u0442\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438 \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u044d\u0442\u0438\u043c \u0432 \u043d\u0430\u0448\u0435\u0439 \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0435.<\/p>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0430 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0440\u0430\u043d\u0435\u0435 \u043f\u0440\u043e\u0439\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438, \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043f\u043e\u0438\u0441\u043a\u0430 \u043e\u043d \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u0435\u043d. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0435\u0433\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 <code>HexGrid.Search<\/code> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u044f\u0447\u0435\u0439\u043a\u0443 \u043a \u0433\u0440\u0430\u043d\u0438\u0446\u0435.<\/p>\n<pre><code class=\"cs\">\t\t\t\tif (neighbor.Distance == int.MaxValue) { \t\t\t\t\tneighbor.Distance = distance; \t\t\t\t\tneighbor.PathFrom = current; \t\t\t\t\tneighbor.SearchHeuristic = \t\t\t\t\t\tneighbor.coordinates.DistanceTo(toCell.coordinates); \t\t\t\t\tfrontier.Add(neighbor); \t\t\t\t}<\/code><\/pre>\n<p>  <\/p>\n<h3>\u041f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442 \u043f\u043e\u0438\u0441\u043a\u0430<\/h3>\n<p>  \u0421 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442 \u043f\u043e\u0438\u0441\u043a\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0434\u043e \u044f\u0447\u0435\u0439\u043a\u0438 \u043f\u043b\u044e\u0441 \u0435\u0451 \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0438. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 <code>HexCell<\/code> \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e.<\/p>\n<pre><code class=\"cs\">\tpublic int SearchPriority { \t\tget { \t\t\treturn distance + SearchHeuristic; \t\t} \t}<\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e, \u0438\u0437\u043c\u0435\u043d\u0438\u043c <code>HexGrid.Search<\/code> \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u044d\u0442\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u043d\u0438\u0446\u044b.<\/p>\n<pre><code class=\"cs\">\t\t\t\tfrontier.Sort( \t\t\t\t\t(x, y) =&gt; x.SearchPriority.CompareTo(y.SearchPriority) \t\t\t\t);<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/b58\/a22\/c9a\/b58a22c9a65a2088309a46c6cbc2d102.png\"><\/div>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/b44\/0a3\/c0a\/b440a3c0aa42dc771ba3a7a0948c835f.png\"><\/div>\n<p>  <i>\u041f\u043e\u0438\u0441\u043a \u0431\u0435\u0437 \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u0438 \u0441 \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u043e\u0439.<\/i><\/p>\n<h3>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u0430\u044f \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0430<\/h3>\n<p>  \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043d\u043e\u0432\u044b\u043c \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0430\u043c \u043f\u043e\u0438\u0441\u043a\u0430 \u043c\u044b \u0438 \u0432 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u0441\u0435\u0442\u0438\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u044f\u0447\u0435\u0435\u043a. \u041e\u0434\u043d\u0430\u043a\u043e \u043d\u0430 \u043e\u0434\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e\u0439 \u043a\u0430\u0440\u0442\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u044f\u0447\u0435\u0439\u043a\u0438, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0435\u0441\u044f \u0432 \u043d\u0435\u0432\u0435\u0440\u043d\u043e\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438. \u0422\u0430\u043a \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0448\u0430\u0433 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0440\u0430\u0432\u043d\u044b 5, \u0430 \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0430 \u043d\u0430 \u0448\u0430\u0433 \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u0441\u0435\u0433\u043e 1. \u0422\u043e \u0435\u0441\u0442\u044c \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0441\u0438\u043b\u044c\u043d\u043e.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043d\u0430 \u0432\u0441\u0435\u0445 \u043a\u0430\u0440\u0442\u0435 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b, \u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0436\u0435 \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043f\u0440\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0438. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0430\u044f \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0430, \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u043d\u0430\u044f \u043d\u0430 5. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043d\u0438\u0437\u0438\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u044f\u0447\u0435\u0435\u043a.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/9a4\/6c7\/ac3\/9a46c7ac3c0df63797bfda1f143f9409.png\"><\/div>\n<p>  <i>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0443 \u00d7 5.<\/i><\/p>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u043b\u0438 \u043d\u0430 \u043a\u0430\u0440\u0442\u0435 \u0435\u0441\u0442\u044c \u0434\u043e\u0440\u043e\u0433\u0438, \u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u043e\u0446\u0435\u043d\u0438\u0442\u044c \u043e\u0441\u0442\u0430\u0432\u0448\u0435\u0435\u0441\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043c\u043e\u0436\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0443\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0438\u043c.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/cd2\/7bb\/dc7\/cd27bbdc7043804a8d2a21ac096a6409.png\"><\/div>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/0af\/017\/2a2\/0af0172a264285358f99b0ece93833a3.png\"><\/div>\n<p>  <i>\u041f\u0435\u0440\u0435\u043e\u0446\u0435\u043d\u0451\u043d\u043d\u0430\u044f \u0438 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u0430\u044f \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0438.<\/i><\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u043d\u0430\u0439\u0434\u0435\u043d \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0438\u0439 \u043f\u0443\u0442\u044c, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043f\u0435\u0440\u0435\u043e\u0446\u0435\u043d\u0438\u0432\u0430\u043b\u0438 \u043e\u0441\u0442\u0430\u0432\u0448\u0435\u0435\u0441\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435. \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u0439 \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u043e\u0439. \u0422\u0430\u043a \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0440\u0430\u0432\u043d\u044b 1, \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0432\u044b\u0431\u043e\u0440\u0430, \u043a\u0440\u043e\u043c\u0435 \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0435 \u0436\u0435 \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043f\u0440\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0438.<\/p>\n<p>  \u0421\u0442\u0440\u043e\u0433\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0432\u043f\u043e\u043b\u043d\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u0436\u0435 \u043c\u0435\u043d\u044c\u0448\u0438\u0435 \u0437\u0430\u0442\u0440\u0430\u0442\u044b, \u043d\u043e \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0443 \u0441\u043b\u0430\u0431\u0435\u0435. \u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0430\u044f \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0430 \u0440\u0430\u0432\u043d\u0430 \u043d\u0443\u043b\u044e, \u0447\u0442\u043e \u0434\u0430\u0451\u0442 \u043d\u0430\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0414\u0435\u0439\u043a\u0441\u0442\u0440\u044b. \u041f\u0440\u0438 \u043d\u0435\u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f A<sup>*<\/sup> (\u043f\u0440\u043e\u0438\u0437\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u00ab\u0410 \u0437\u0432\u0435\u0437\u0434\u0430\u00bb).<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u0447\u0435\u043c\u0443 \u0435\u0433\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 A*?<\/b><\/p>\n<div class=\"spoiler_text\">\u0418\u0434\u0435\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u0432 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0414\u0435\u0439\u043a\u0441\u0442\u0440\u044b \u0432\u043f\u0435\u0440\u0432\u044b\u0435 \u0431\u044b\u043b\u0430 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0430 \u041d\u0438\u043b\u044c\u0441\u043e\u043c \u041d\u0438\u043b\u044c\u0441\u0441\u043e\u043d\u043e\u043c. \u041e\u043d \u043d\u0430\u0437\u0432\u0430\u043b \u0441\u0432\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 A1. \u041f\u043e\u0437\u0436\u0435 \u0411\u0435\u0440\u0442\u0440\u0430\u043c \u0420\u0430\u0444\u0430\u044d\u043b\u044c \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b \u043b\u0443\u0447\u0448\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u043d \u043d\u0430\u0437\u0432\u0430\u043b A2. \u0417\u0430\u0442\u0435\u043c \u041f\u0438\u0442\u0435\u0440 \u0425\u0430\u0440\u0442 \u0434\u043e\u043a\u0430\u0437\u0430\u043b, \u0447\u0442\u043e \u043f\u0440\u0438 \u0445\u043e\u0440\u043e\u0448\u0435\u0439 \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0435 A2 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u0435\u043d, \u0442\u043e \u0435\u0441\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0445\u043e\u0440\u043e\u0448\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0431\u044b\u0442\u044c \u043d\u0435 \u043c\u043e\u0436\u0435\u0442. \u042d\u0442\u043e \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043b\u043e \u0435\u0433\u043e \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c A<sup>*<\/sup>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0435\u0433\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c, \u0442\u043e \u0435\u0441\u0442\u044c A3 \u0438\u043b\u0438 A4 \u043d\u0435 \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f. \u0422\u0430\u043a \u0447\u0442\u043e \u0434\u0430, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c A<sup>*<\/sup> \u2014 \u044d\u0442\u043e \u043b\u0443\u0447\u0448\u0435\u0435, \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c, \u043d\u043e \u043e\u043d \u0445\u043e\u0440\u043e\u0448 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0445\u043e\u0440\u043e\u0448\u0430 \u0435\u0433\u043e \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0430.<\/div>\n<\/div>\n<p>  <a href=\"https:\/\/catlikecoding.com\/unity\/tutorials\/hex-map\/part-16\/smarter-searching\/smarter-searching.unitypackage\" rel=\"nofollow\">unitypackage<\/a><\/p>\n<h2>\u041e\u0447\u0435\u0440\u0435\u0434\u044c \u0441 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u043c<\/h2>\n<p>  \u0425\u043e\u0442\u044c A<sup>*<\/sup> \u0438 \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043d\u0430\u0448\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0430, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438. \u041a\u0430\u043a \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b\u043e\u0441\u044c \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u043c, \u043d\u043e \u0435\u0451 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0435\u0451 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<p>  \u041d\u0430\u0448\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0430. \u0422\u0430\u043a\u0436\u0435 \u043e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0430 \u044f\u0447\u0435\u0439\u043a\u0438, \u0443\u0436\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0435\u0439\u0441\u044f \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438. \u0412 \u0438\u0434\u0435\u0430\u043b\u0435 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0435\u0451, \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u044f \u043f\u043e\u0438\u0441\u043a \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0443 \u0438 \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u043c\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0439.<\/p>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u0438<\/h3>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <code>HexCellPriorityQueue<\/code> \u0441 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043e\u0431\u0449\u0438\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438. \u0414\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0439 \u043c\u0435\u0442\u043e\u0434 <code>Clear<\/code> \u0434\u043b\u044f \u0441\u0431\u0440\u043e\u0441\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u0447\u0442\u043e\u0431\u044b \u0435\u0451 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e.<\/p>\n<pre><code class=\"cs\">using System.Collections.Generic;  public class HexCellPriorityQueue {  \tList&lt;HexCell&gt; list = new List&lt;HexCell&gt;();  \tpublic void Enqueue (HexCell cell) { \t}  \tpublic HexCell Dequeue () { \t\treturn null; \t} \t \tpublic void Change (HexCell cell) { \t} \t \tpublic void Clear () { \t\tlist.Clear(); \t} }<\/code><\/pre>\n<p>  \u041c\u044b \u0445\u0440\u0430\u043d\u0438\u043c \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u044b \u044f\u0447\u0435\u0435\u043a \u0432 \u0441\u0430\u043c\u0438\u0445 \u044f\u0447\u0435\u0439\u043a\u0430\u0445. \u0422\u043e \u0435\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0434 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u044f\u0447\u0435\u0439\u043a\u0438 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0435\u0451 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0437\u0430\u0434\u0430\u043d. \u041d\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0430 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0437\u043d\u0430\u0442\u044c, \u043a\u0430\u043a\u0438\u043c \u0431\u044b\u043b \u0441\u0442\u0430\u0440\u044b\u0439 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u044d\u0442\u043e \u0432 <code>Change<\/code> \u043a\u0430\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440.<\/p>\n<pre><code class=\"cs\">\tpublic void Change (HexCell cell, int oldPriority) { \t}<\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0437\u043d\u0430\u0442\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044f\u0447\u0435\u0435\u043a \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>Count<\/code>. \u041f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u043e\u043b\u0435, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442 \u0438 \u0434\u0435\u043a\u0440\u0435\u043c\u0435\u043d\u0442.<\/p>\n<pre><code class=\"cs\">\tint count = 0;  \tpublic int Count { \t\tget { \t\t\treturn count; \t\t} \t}  \tpublic void Enqueue (HexCell cell) { \t\tcount += 1; \t}  \tpublic HexCell Dequeue () { \t\tcount -= 1; \t\treturn null; \t} \t \t\u2026 \t \tpublic void Clear () { \t\tlist.Clear(); \t\tcount = 0; \t}<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c<\/h3>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u044f\u0447\u0435\u0439\u043a\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0451 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442 \u043a\u0430\u043a \u0438\u043d\u0434\u0435\u043a\u0441, \u043e\u0431\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u043a\u0430\u043a \u0441 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c.<\/p>\n<pre><code class=\"cs\">\tpublic void Enqueue (HexCell cell) { \t\tcount += 1; \t\tint priority = cell.SearchPriority; \t\tlist[priority] = cell; \t}<\/code><\/pre>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u0438\u043d\u043d\u044b\u0439, \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0432\u044b\u0439\u0434\u0435\u043c \u0437\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u044b. \u041c\u043e\u0436\u043d\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u044d\u0442\u043e\u0433\u043e, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0443\u0441\u0442\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u043f\u043e\u043a\u0430 \u043e\u043d \u043d\u0435 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0435\u0442 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u043e\u0439 \u0434\u043b\u0438\u043d\u044b. \u042d\u0442\u0438 \u043f\u0443\u0441\u0442\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043d\u0435 \u0441\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u044f\u0447\u0435\u0439\u043a\u0443, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u0432 \u0441\u043f\u0438\u0441\u043e\u043a <code>null<\/code>.<\/p>\n<pre><code class=\"cs\">\t\tint priority = cell.SearchPriority; \t\twhile (priority &gt;= list.Count) { \t\t\tlist.Add(null); \t\t} \t\tlist[priority] = cell;<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e77\/000\/fec\/e77000feca5c0bfdb769062356ca9935.png\"><\/div>\n<p>  <i>\u0421\u043f\u0438\u0441\u043e\u043a \u0441 \u0434\u044b\u0440\u0430\u043c\u0438.<\/i><\/p>\n<p>  \u041d\u043e \u0442\u0430\u043a \u043c\u044b \u0445\u0440\u0430\u043d\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0435 \u043d\u0430 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442, \u0430 \u0438\u0445 \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e. \u0427\u0442\u043e\u0431\u044b \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u044f\u0447\u0435\u0439\u043a\u0438 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u043c, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0441\u043f\u0438\u0441\u043e\u043a. \u0425\u043e\u0442\u044f \u043c\u044b \u0438 \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442, \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a <code>HexCell<\/code> \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0438\u0445 \u0432\u043c\u0435\u0441\u0442\u0435. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u044f\u0447\u0435\u0435\u043a, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u0443\u044e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c.<\/p>\n<pre><code class=\"cs\">\tpublic HexCell NextWithSamePriority { get; set; }<\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b <code>HexCellPriorityQueue.Enqueue<\/code> \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u043b \u043d\u043e\u0432\u0443\u044e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u044f\u0447\u0435\u0439\u043a\u0443 \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441 \u0442\u0435\u043c \u0436\u0435 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u043c, \u043f\u0435\u0440\u0435\u0434 \u0435\u0433\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435\u043c.<\/p>\n<pre><code class=\"cs\">\t\tcell.NextWithSamePriority = list[priority]; \t\tlist[priority] = cell;<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/45b\/082\/87c\/45b08287cf76c4636d7a673869aa39b5.png\"><\/div>\n<p>  <i>\u0421\u043f\u0438\u0441\u043e\u043a \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441\u043f\u0438\u0441\u043a\u043e\u0432.<\/i><\/p>\n<h3>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438<\/h3>\n<p>  \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u044f\u0447\u0435\u0439\u043a\u0438 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0441 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u043c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u0441\u043f\u0438\u0441\u043a\u0443 \u043f\u043e \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u043c\u0443 \u043d\u0435\u043f\u0443\u0441\u0442\u043e\u043c\u0443 \u0438\u043d\u0434\u0435\u043a\u0441\u0443. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0431\u043e\u0439\u0434\u0451\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0432 \u0446\u0438\u043a\u043b\u0435, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0430\u0439\u0434\u0451\u043c \u0435\u0433\u043e. \u0415\u0441\u043b\u0438 \u043d\u0435 \u043d\u0430\u0439\u0434\u0451\u043c, \u0442\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0443\u0441\u0442\u0430 \u0438 \u043c\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c <code>null<\/code>.<\/p>\n<p>  \u0418\u0437 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u0439 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043b\u044e\u0431\u0443\u044e \u044f\u0447\u0435\u0439\u043a\u0443, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432\u0441\u0435 \u043e\u043d\u0438 \u0438\u043c\u0435\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442. \u041f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u044f\u0447\u0435\u0439\u043a\u0443 \u0438\u0437 \u043d\u0430\u0447\u0430\u043b\u0430 \u0446\u0435\u043f\u043e\u0447\u043a\u0438.<\/p>\n<pre><code class=\"cs\">\tpublic HexCell Dequeue () { \t\tcount -= 1; \t\tfor (int i = 0; i &lt; list.Count; i++) { \t\t\tHexCell cell = list[i]; \t\t\tif (cell != null) { \t\t\t\treturn cell; \t\t\t} \t\t} \t\treturn null; \t}<\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043e\u0441\u0442\u0430\u0432\u0448\u0443\u044e\u0441\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0443, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u044f\u0447\u0435\u0439\u043a\u0443 \u0441 \u0442\u0435\u043c \u0436\u0435 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u043c \u043a\u0430\u043a \u043d\u043e\u0432\u043e\u0435 \u043d\u0430\u0447\u0430\u043b\u043e. \u0415\u0441\u043b\u0438 \u043d\u0430 \u044d\u0442\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u0432 \u0431\u044b\u043b\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0430 \u044f\u0447\u0435\u0439\u043a\u0430, \u0442\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f <code>null<\/code> \u0438 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f.<\/p>\n<pre><code class=\"cs\">\t\t\tif (cell != null) { \t\t\t\tlist[i] = cell.NextWithSamePriority; \t\t\t\treturn cell; \t\t\t}<\/code><\/pre>\n<p>  <\/p>\n<h3>\u041e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u0430<\/h3>\n<p>  \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043d\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0438\u0442\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u044f\u0447\u0435\u0439\u043a\u0438. \u041c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u043e\u0438\u0441\u043a\u0430 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0433\u043e \u043d\u0435\u043f\u0443\u0441\u0442\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430, \u043d\u043e \u043c\u044b \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u043d\u044b \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u0441 \u043d\u0443\u043b\u044f. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442 \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u043f\u043e\u0438\u0441\u043a \u0441 \u043d\u0435\u0433\u043e. \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043f\u043e \u0441\u0443\u0442\u0438 \u0440\u0430\u0432\u0435\u043d \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u0438.<\/p>\n<pre><code class=\"cs\">\tint minimum = int.MaxValue;  \t\u2026 \t \tpublic void Clear () { \t\tlist.Clear(); \t\tcount = 0; \t\tminimum = int.MaxValue; \t}<\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u044f\u0447\u0435\u0439\u043a\u0438 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u043c\u0438\u043d\u0438\u043c\u0443\u043c.<\/p>\n<pre><code class=\"cs\">\tpublic void Enqueue (HexCell cell) { \t\tcount += 1; \t\tint priority = cell.SearchPriority; \t\tif (priority &lt; minimum) { \t\t\tminimum = priority; \t\t} \t\t\u2026 \t}<\/code><\/pre>\n<p>  \u0418 \u043f\u0440\u0438 \u0432\u044b\u0432\u043e\u0434\u0435 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043b\u044f \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443, \u0430 \u043d\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441 \u043d\u0443\u043b\u044f.<\/p>\n<pre><code class=\"cs\">\tpublic HexCell Dequeue () { \t\tcount -= 1; \t\tfor (; minimum &lt; list.Count; minimum++) { \t\t\tHexCell cell = list[minimum]; \t\t\tif (cell != null) { \t\t\t\tlist[minimum] = cell.NextWithSamePriority; \t\t\t\treturn cell; \t\t\t} \t\t} \t\treturn null; \t}<\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u043e\u0431\u044a\u0451\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u043e\u0431\u0445\u043e\u0434 \u0432 \u0446\u0438\u043a\u043b\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u0432.<\/p>\n<h3>\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u0432<\/h3>\n<p>  \u041f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0430 \u044f\u0447\u0435\u0439\u043a\u0438 \u043e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0443\u0434\u0430\u043b\u044f\u0442\u044c\u0441\u044f \u0438\u0437 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430, \u0447\u0430\u0441\u0442\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u0446\u0435\u043f\u043e\u0447\u043a\u0435, \u043f\u043e\u043a\u0430 \u043c\u044b \u043d\u0435 \u043d\u0430\u0439\u0434\u0451\u043c \u0435\u0451.<\/p>\n<p>  \u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0433\u043e\u043b\u043e\u0432\u0430 \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u044f\u0447\u0435\u0439\u043a\u043e\u0439, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u044f\u0447\u0435\u0439\u043a\u0443. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u0431\u0440\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u044f\u0447\u0435\u0439\u043a\u0443, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u0438\u043d\u0434\u0435\u043a\u0441\u0443 \u0435\u0441\u0442\u044c \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u043d\u0430 \u044f\u0447\u0435\u0439\u043a\u0430.<\/p>\n<pre><code class=\"cs\">\tpublic void Change (HexCell cell, int oldPriority) { \t\tHexCell current = list[oldPriority]; \t\tHexCell next = current.NextWithSamePriority; \t}<\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0442\u0435\u043a\u0443\u0449\u0430\u044f \u044f\u0447\u0435\u0439\u043a\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0437\u043c\u0435\u043d\u0438\u0432\u0448\u0435\u0439\u0441\u044f \u044f\u0447\u0435\u0439\u043a\u043e\u0439, \u0442\u043e \u044d\u0442\u043e \u0433\u043e\u043b\u043e\u0432\u043d\u0430\u044f \u044f\u0447\u0435\u0439\u043a\u0430 \u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0442\u0441\u0435\u0447\u044c \u0435\u0451, \u043a\u0430\u043a \u0431\u0443\u0434\u0442\u043e \u0432\u044b\u0432\u0435\u043b\u0438 \u0435\u0451 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438.<\/p>\n<pre><code class=\"cs\">\t\tHexCell current = list[oldPriority]; \t\tHexCell next = current.NextWithSamePriority; \t\tif (current == cell) { \t\t\tlist[oldPriority] = next; \t\t}<\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a, \u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u0446\u0435\u043f\u043e\u0447\u043a\u0435, \u043f\u043e\u043a\u0430 \u043c\u044b \u043d\u0435 \u043e\u043a\u0430\u0436\u0435\u043c\u0441\u044f \u0432 \u044f\u0447\u0435\u0439\u043a\u0435 \u043f\u0435\u0440\u0435\u0434 \u0438\u0437\u043c\u0435\u043d\u0438\u0432\u0448\u0435\u0439\u0441\u044f \u044f\u0447\u0435\u0439\u043a\u043e\u0439. \u041e\u043d\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u044f\u0447\u0435\u0439\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u044b\u043b\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0430.<\/p>\n<pre><code class=\"cs\">\t\tif (current == cell) { \t\t\tlist[oldPriority] = next; \t\t} \t\telse { \t\t\twhile (next != cell) { \t\t\t\tcurrent = next; \t\t\t\tnext = current.NextWithSamePriority; \t\t\t} \t\t}<\/code><\/pre>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0438\u0432\u0448\u0443\u044e\u0441\u044f \u044f\u0447\u0435\u0439\u043a\u0443 \u0438\u0437 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430, \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0432 \u0435\u0451.<\/p>\n<pre><code class=\"cs\">\t\t\twhile (next != cell) { \t\t\t\tcurrent = next; \t\t\t\tnext = current.NextWithSamePriority; \t\t\t} \t\t\tcurrent.NextWithSamePriority = cell.NextWithSamePriority;<\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u044f\u0447\u0435\u0439\u043a\u0438 \u0435\u0451 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043d\u043e\u0432\u0430, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0430 \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0441\u0432\u043e\u0435\u0433\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0430.<\/p>\n<pre><code class=\"cs\">\tpublic void Change (HexCell cell, int oldPriority) { \t\t\u2026 \t\tEnqueue(cell); \t}<\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 <code>Enqueue<\/code> \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0441\u0447\u0451\u0442\u0447\u0438\u043a, \u043d\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043c\u044b \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u043e\u0432\u0443\u044e \u044f\u0447\u0435\u0439\u043a\u0443. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u043c\u043f\u0435\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e, \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0434\u0435\u043a\u0440\u0435\u043c\u0435\u043d\u0442 \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0430.<\/p>\n<pre><code class=\"cs\">\t\tEnqueue(cell); \t\tcount -= 1;<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u0438<\/h3>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u0448\u0435\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u044c\u044e \u0441 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u043c \u0432 <code>HexGrid<\/code>. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0434\u043d\u043e\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430, \u043c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043f\u043e\u0438\u0441\u043a\u0430.<\/p>\n<pre><code class=\"cs\">\tHexCellPriorityQueue searchFrontier; \t \t\u2026 \t \tIEnumerator Search (HexCell fromCell, HexCell toCell) { \t\tif (searchFrontier == null) { \t\t\tsearchFrontier = new HexCellPriorityQueue(); \t\t} \t\telse { \t\t\tsearchFrontier.Clear(); \t\t} \t\t \t\t\u2026 \t}<\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0434 \u043d\u0430\u0447\u0430\u043b\u043e\u043c \u0446\u0438\u043a\u043b\u0430 \u043c\u0435\u0442\u043e\u0434 <code>Search<\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u043d\u0435\u0441\u0442\u0438 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c <code>fromCell<\/code>, \u0430 \u043a\u0430\u0436\u0434\u0430\u044f \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u0432\u044b\u0432\u043e\u0434\u0430 \u044f\u0447\u0435\u0439\u043a\u0438 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438. \u042d\u0442\u0438\u043c \u043c\u044b \u0437\u0430\u043c\u0435\u043d\u0438\u043c \u0441\u0442\u0430\u0440\u044b\u0439 \u043a\u043e\u0434 \u0433\u0440\u0430\u043d\u0438\u0446\u044b.<\/p>\n<pre><code class=\"cs\">\t\tWaitForSeconds delay = new WaitForSeconds(1 \/ 60f); \/\/\t\tList&lt;HexCell&gt; frontier = new List&lt;HexCell&gt;(); \t\tfromCell.Distance = 0; \/\/\t\tfrontier.Add(fromCell); \t\tsearchFrontier.Enqueue(fromCell); \t\twhile (searchFrontier.Count &gt; 0) { \t\t\tyield return delay; \t\t\tHexCell current = searchFrontier.Dequeue(); \/\/\t\t\tfrontier.RemoveAt(0); \t\t\t\u2026 \t\t}<\/code><\/pre>\n<p>  \u0418\u0437\u043c\u0435\u043d\u0438\u043c \u043a\u043e\u0434 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u043b \u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u043b \u0438 \u0441\u043e\u0441\u0435\u0434\u0430. \u041f\u0435\u0440\u0435\u0434 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0439 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442.<\/p>\n<pre><code class=\"cs\">\t\t\t\tif (neighbor.Distance == int.MaxValue) { \t\t\t\t\tneighbor.Distance = distance; \t\t\t\t\tneighbor.PathFrom = current; \t\t\t\t\tneighbor.SearchHeuristic = \t\t\t\t\t\tneighbor.coordinates.DistanceTo(toCell.coordinates); \/\/\t\t\t\t\tfrontier.Add(neighbor); \t\t\t\t\tsearchFrontier.Enqueue(neighbor); \t\t\t\t} \t\t\t\telse if (distance &lt; neighbor.Distance) { \t\t\t\t\tint oldPriority = neighbor.SearchPriority; \t\t\t\t\tneighbor.Distance = distance; \t\t\t\t\tneighbor.PathFrom = current; \t\t\t\t\tsearchFrontier.Change(neighbor, oldPriority); \t\t\t\t}<\/code><\/pre>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043d\u0430\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0433\u0440\u0430\u043d\u0438\u0446\u0443.<\/p>\n<pre><code class=\"cs\">\/\/\t\t\t\tfrontier.Sort( \/\/\t\t\t\t\t(x, y) =&gt; x.SearchPriority.CompareTo(y.SearchPriority) \/\/\t\t\t\t);<\/code><\/pre>\n<p>  <\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 64.9688%;\"><iframe src=\"https:\/\/gfycat.com\/ifr\/SlimIdioticFlyingfox\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  <i>\u041f\u043e\u0438\u0441\u043a \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0441 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u043c.<\/i><\/p>\n<p>  \u041a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c \u0440\u0430\u043d\u0435\u0435, \u043d\u0430\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0438\u0439 \u043f\u0443\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u044f\u0447\u0435\u0435\u043a. \u041d\u0430\u0448\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u043a, \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u043e\u0442 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0443\u0442\u0438. \u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c, \u0438 \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0438\u0437 \u0433\u043e\u043b\u043e\u0432\u044b \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0430, \u043e\u043d\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0445\u043e\u0434\u044f\u0442 \u043d\u0430 \u0441\u0442\u0435\u043a\u0438, \u0447\u0435\u043c \u043d\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u0438. \u042f\u0447\u0435\u0439\u043a\u0438, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c\u0438, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u0435\u0440\u0432\u044b\u043c\u0438. \u041f\u043e\u0431\u043e\u0447\u043d\u044b\u0439 \u044d\u0444\u0444\u0435\u043a\u0442 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u043a\u043b\u043e\u043d\u0435\u043d \u043a \u0437\u0438\u0433\u0437\u0430\u0433\u0430\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442\u0441\u044f \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0437\u0438\u0433\u0437\u0430\u0433\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0443\u0442\u0435\u0439. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0442\u0430\u043a\u0438\u0435 \u043f\u0443\u0442\u0438 \u043e\u0431\u044b\u0447\u043d\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043b\u0443\u0447\u0448\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044d\u0442\u043e\u0442 \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0439 \u044d\u0444\u0444\u0435\u043a\u0442 \u043d\u0430\u043c \u043d\u0430 \u043f\u043e\u043b\u044c\u0437\u0443.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/b44\/0a3\/c0a\/b440a3c0aa42dc771ba3a7a0948c835f.png\"><\/div>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/908\/1e9\/cc5\/9081e9cc5b0ea1d6f4309b6221eab1ac.png\"><\/div>\n<p>  <i>\u041e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u043c.<\/i><\/p>\n<p>  <a href=\"https:\/\/catlikecoding.com\/unity\/tutorials\/hex-map\/part-16\/priority-queue\/priority-queue.unitypackage\" rel=\"nofollow\">unitypackage<\/a><\/p>\n<h1>\u0427\u0430\u0441\u0442\u044c 17: \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435<\/h1>\n<p>  <\/p>\n<ul>\n<li>\u041d\u0430\u0445\u043e\u0434\u0438\u043c \u043f\u0443\u0442\u0438 \u0434\u043b\u044f \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f.<\/li>\n<li>\u0421\u0440\u0430\u0437\u0443 \u0436\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u043f\u0443\u0442\u0438.<\/li>\n<li>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a.<\/li>\n<li>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0443\u0442\u044c.<\/li>\n<\/ul>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u0445\u043e\u0434\u044b \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0443\u0441\u043a\u043e\u0440\u0438\u043c \u043f\u043e\u0438\u0441\u043a.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c4d\/572\/9cc\/c4d5729ccbf9cc994b7c8328950e6f5b.jpg\"><\/div>\n<p>  <i>\u041f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u0435 \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0445\u043e\u0434\u043e\u0432.<\/i><\/p>\n<h2>\u041f\u043e\u0448\u0430\u0433\u043e\u0432\u043e\u0435 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435<\/h2>\n<p>  \u0421\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0438\u0433\u0440\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0441\u0435\u0442\u043a\u0438 \u0448\u0435\u0441\u0442\u0438\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432, \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u044b\u043c\u0438. \u041f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u043f\u043e \u043a\u0430\u0440\u0442\u0435 \u043e\u0442\u0440\u044f\u0434\u044b \u0438\u043c\u0435\u044e\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u0443\u044e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u0437\u0430 \u043e\u0434\u0438\u043d \u0445\u043e\u0434.<\/p>\n<h3>\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c<\/h3>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 <code>HexGrid.FindPath<\/code> \u0438 \u0432 <code>HexGrid.Search<\/code> \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>speed<\/code>. \u041e\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0430\u0441 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0439 \u043d\u0430 \u043e\u0434\u0438\u043d \u0445\u043e\u0434.<\/p>\n<pre><code class=\"cs\">\tpublic void FindPath (HexCell fromCell, HexCell toCell, int speed) { \t\tStopAllCoroutines(); \t\tStartCoroutine(Search(fromCell, toCell, speed)); \t}  \tIEnumerator Search (HexCell fromCell, HexCell toCell, int speed) { \t\t\u2026 \t}<\/code><\/pre>\n<p>  \u0420\u0430\u0437\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u043e\u0442\u0440\u044f\u0434\u043e\u0432 \u0432 \u0438\u0433\u0440\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438. \u041a\u0430\u0432\u0430\u043b\u0435\u0440\u0438\u044f \u0431\u044b\u0441\u0442\u0440\u0430, \u043f\u0435\u0445\u043e\u0442\u0430 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0430, \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u0423 \u043d\u0430\u0441 \u0435\u0449\u0451 \u043d\u0435\u0442 \u043e\u0442\u0440\u044f\u0434\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043a\u0430 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u0443\u044e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043e\u0437\u044c\u043c\u0451\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 24. \u042d\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043d\u0435 \u0434\u0435\u043b\u044f\u0449\u0435\u0435\u0441\u044f \u043d\u0430 5 (\u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e). \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u0430\u043a \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f <code>FindPath<\/code> \u0432 <code>HexMapEditor.HandleInput<\/code> \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u0443\u044e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c.<\/p>\n<pre><code class=\"cs\">\t\t\tif (editMode) { \t\t\t\tEditCells(currentCell); \t\t\t} \t\t\telse if ( \t\t\t\tInput.GetKey(KeyCode.LeftShift) &amp;&amp; searchToCell != currentCell \t\t\t) { \t\t\t\tif (searchFromCell) { \t\t\t\t\tsearchFromCell.DisableHighlight(); \t\t\t\t} \t\t\t\tsearchFromCell = currentCell; \t\t\t\tsearchFromCell.EnableHighlight(Color.blue); \t\t\t\tif (searchToCell) { \t\t\t\t\thexGrid.FindPath(searchFromCell, searchToCell, 24); \t\t\t\t} \t\t\t} \t\t\telse if (searchFromCell &amp;&amp; searchFromCell != currentCell) { \t\t\t\tsearchToCell = currentCell; \t\t\t\thexGrid.FindPath(searchFromCell, searchToCell, 24); \t\t\t}<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0425\u043e\u0434\u044b<\/h3>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u0449\u0438\u0445 \u0437\u0430\u0442\u0440\u0430\u0442 \u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043f\u043e \u043f\u0443\u0442\u0438 \u043d\u0430\u043c \u0442\u0430\u043a\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0437\u043d\u0430\u0442\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0445\u043e\u0434\u043e\u0432 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043f\u043e \u043d\u0435\u043c\u0443. \u041d\u043e \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0435. \u0415\u0451 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c, \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0432 \u043f\u0440\u043e\u0439\u0434\u0435\u043d\u043d\u043e\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043d\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c. \u0422\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430, \u043c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u043c \u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c. \u0422\u043e \u0435\u0441\u0442\u044c \u043e\u0431\u0449\u0438\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 24 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0445\u043e\u0434\u0443 0. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0432\u0435\u0441\u044c \u043f\u0443\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0439\u0442\u0438 \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u0445\u043e\u0434\u0435. \u0415\u0441\u043b\u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0438 30, \u0442\u043e \u044d\u0442\u043e \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0445\u043e\u0434 1. \u0427\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0434\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438, \u043e\u0442\u0440\u044f\u0434\u0443 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0441\u0451 \u0441\u0432\u043e\u0451 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u0445\u043e\u0434\u0443 \u0438 \u0432 \u0447\u0430\u0441\u0442\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0445\u043e\u0434\u0430.<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0445\u043e\u0434 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u044f\u0447\u0435\u0439\u043a\u0438 \u0438 \u0432\u0441\u0435\u0445 \u0435\u0451 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 <code>HexGrid.Search<\/code>. \u0425\u043e\u0434 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u044f\u0447\u0435\u0439\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u043f\u0440\u044f\u043c\u043e \u043f\u0435\u0440\u0435\u0434 \u043e\u0431\u0445\u043e\u0434\u043e\u043c \u0432 \u0446\u0438\u043a\u043b\u0435 \u0441\u043e\u0441\u0435\u0434\u0435\u0439. \u0425\u043e\u0434 \u0441\u043e\u0441\u0435\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u044b \u043d\u0430\u0439\u0434\u0451\u043c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0434\u043e \u043d\u0435\u0433\u043e.<\/p>\n<pre><code class=\"cs\">\t\t\tint currentTurn = current.Distance \/ speed;  \t\t\tfor (HexDirection d = HexDirection.NE; d &lt;= HexDirection.NW; d++) { \t\t\t\t\u2026 \t\t\t\tint distance = current.Distance; \t\t\t\tif (current.HasRoadThroughEdge(d)) { \t\t\t\t\tdistance += 1; \t\t\t\t} \t\t\t\telse if (current.Walled != neighbor.Walled) { \t\t\t\t\tcontinue; \t\t\t\t} \t\t\t\telse { \t\t\t\t\tdistance += edgeType == HexEdgeType.Flat ? 5 : 10; \t\t\t\t\tdistance += neighbor.UrbanLevel + neighbor.FarmLevel + \t\t\t\t\t\tneighbor.PlantLevel; \t\t\t\t}  \t\t\t\tint turn = distance \/ speed;  \t\t\t\t\u2026 \t\t\t}<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0423\u0442\u0435\u0440\u044f\u043d\u043d\u043e\u0435 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u0415\u0441\u043b\u0438 \u0445\u043e\u0434 \u0441\u043e\u0441\u0435\u0434\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0445\u043e\u0434\u0430, \u0442\u043e \u043c\u044b \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u043b\u0438 \u0433\u0440\u0430\u043d\u0438\u0446\u0443 \u0445\u043e\u0434\u0430. \u0415\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u0441\u043e\u0441\u0435\u0434\u0430, \u0431\u044b\u043b\u043e \u0440\u0430\u0432\u043d\u043e 1, \u0442\u043e \u0432\u0441\u0451 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e. \u041d\u043e \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0432 \u0441\u043e\u0441\u0435\u0434\u043d\u044e\u044e \u044f\u0447\u0435\u0439\u043a\u0443 \u0431\u043e\u043b\u0435\u0435 \u0437\u0430\u0442\u0440\u0430\u0442\u043d\u043e, \u0442\u043e \u0432\u0441\u0451 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u0435\u0435.<\/p>\n<p>  \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c\u0441\u044f \u043f\u043e \u043e\u0434\u043d\u043e\u0440\u043e\u0434\u043d\u043e\u0439 \u043a\u0430\u0440\u0442\u0435, \u0442\u043e \u0435\u0441\u0442\u044c \u0434\u043b\u044f \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u044f \u0432 \u043a\u0430\u0436\u0434\u0443\u044e \u044f\u0447\u0435\u0439\u043a\u0443 \u043d\u0443\u0436\u043d\u043e 5 \u0435\u0434\u0438\u043d\u0438\u0446 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f. \u041d\u0430\u0448\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0440\u0430\u0432\u043d\u0430 24. \u0427\u0435\u0440\u0435\u0437 \u0447\u0435\u0442\u044b\u0440\u0435 \u0448\u0430\u0433\u0430 \u043c\u044b \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043b\u0438 20 \u0435\u0434\u0438\u043d\u0438\u0446 \u0438\u0437 \u043d\u0430\u0448\u0435\u0433\u043e \u0437\u0430\u043f\u0430\u0441\u0430 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f, \u0438 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c 4. \u041d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0448\u0430\u0433\u0435 \u0441\u043d\u043e\u0432\u0430 \u043d\u0443\u0436\u043d\u043e 5 \u0435\u0434\u0438\u043d\u0438\u0446, \u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0430 \u043e\u0434\u043d\u0443 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043c\u0435\u044e\u0449\u0438\u0445\u0441\u044f. \u0427\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435?<\/p>\n<p>  \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0432\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u043a \u0442\u0430\u043a\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438. \u041f\u0435\u0440\u0432\u044b\u0439 \u2014 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u043e\u0442\u0440\u044f\u0434\u0443 \u0432\u043e\u0439\u0442\u0438 \u0432 \u043f\u044f\u0442\u0443\u044e \u044f\u0447\u0435\u0439\u043a\u0443 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u0445\u043e\u0434\u0435, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f. \u0412\u0442\u043e\u0440\u043e\u0439 \u2014 \u0437\u0430\u043f\u0440\u0435\u0442\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0445\u043e\u0434\u0430, \u0442\u043e \u0435\u0441\u0442\u044c \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u043e\u0447\u043a\u0438 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0443\u0442\u0435\u0440\u044f\u043d\u044b.<\/p>\n<p>  \u0412\u044b\u0431\u043e\u0440 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0438\u0433\u0440\u044b. \u0412 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0431\u043e\u043b\u044c\u0448\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0438\u0433\u0440\u0430\u043c, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0442\u0440\u044f\u0434\u044b \u043c\u043e\u0433\u0443\u0442 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0432\u0441\u0435\u0433\u043e \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0448\u0430\u0433\u043e\u0432 \u0437\u0430 \u0445\u043e\u0434, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0438\u0433\u0440 \u0441\u0435\u0440\u0438\u0438 Civilization. \u042d\u0442\u043e \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u043e\u0442\u0440\u044f\u0434\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u043c\u043e\u0433\u0443\u0442 \u0441\u0434\u0432\u0438\u043d\u0443\u0442\u044c\u0441\u044f \u0445\u043e\u0442\u044f \u0431\u044b \u043d\u0430 \u043e\u0434\u043d\u0443 \u044f\u0447\u0435\u0439\u043a\u0443 \u0437\u0430 \u0445\u043e\u0434. \u0415\u0441\u043b\u0438 \u043e\u0442\u0440\u044f\u0434\u044b \u043c\u043e\u0433\u0443\u0442 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043c\u043d\u043e\u0433\u043e \u044f\u0447\u0435\u0435\u043a \u0437\u0430 \u0445\u043e\u0434, \u043a\u0430\u043a \u0432 Age of Wonders \u0438\u043b\u0438 \u0432 Battle for Wesnoth, \u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0432\u0442\u043e\u0440\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442.<\/p>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c 24, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u044b\u0431\u0435\u0440\u0435\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434. \u0427\u0442\u043e\u0431\u044b \u043e\u043d \u043d\u0430\u0447\u0430\u043b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043d\u0430 \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u0435 \u0432 \u0441\u043e\u0441\u0435\u0434\u043d\u044e\u044e \u044f\u0447\u0435\u0439\u043a\u0443 \u043f\u0435\u0440\u0435\u0434 \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0435\u0451 \u043a \u0442\u0435\u043a\u0443\u0449\u0435\u043c\u0443 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044e.<\/p>\n<pre><code class=\"cs\">\/\/\t\t\t\tint distance = current.Distance; \t\t\t\tint moveCost; \t\t\t\tif (current.HasRoadThroughEdge(d)) { \t\t\t\t\tmoveCost = 1; \t\t\t\t} \t\t\t\telse if (current.Walled != neighbor.Walled) { \t\t\t\t\tcontinue; \t\t\t\t} \t\t\t\telse { \t\t\t\t\tmoveCost = edgeType == HexEdgeType.Flat ? 5 : 10; \t\t\t\t\tmoveCost  += neighbor.UrbanLevel + neighbor.FarmLevel + \t\t\t\t\t\tneighbor.PlantLevel; \t\t\t\t}  \t\t\t\tint distance = current.Distance + moveCost; \t\t\t\tint turn = distance \/ speed;<\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u044b \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0451\u043c \u0433\u0440\u0430\u043d\u0438\u0446\u0443 \u0445\u043e\u0434\u0430, \u0442\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432\u0441\u0435 \u043e\u0447\u043a\u0438 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0445\u043e\u0434\u0430. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e, \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u043c\u043d\u043e\u0436\u0438\u0432 \u0445\u043e\u0434 \u043d\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435.<\/p>\n<pre><code class=\"cs\">\t\t\t\tint distance = current.Distance + moveCost; \t\t\t\tint turn = distance \/ speed; \t\t\t\tif (turn &gt; currentTurn) { \t\t\t\t\tdistance = turn * speed + moveCost; \t\t\t\t}<\/code><\/pre>\n<p>  \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u0445\u043e\u0434 \u0432 \u0447\u0435\u0442\u0432\u0451\u0440\u0442\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0435 \u0441 4 \u043d\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043e\u0447\u043a\u0430\u043c\u0438 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f. \u042d\u0442\u0438 \u043f\u043e\u0442\u0435\u0440\u044f\u043d\u043d\u044b\u0435 \u043e\u0447\u043a\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a \u0437\u0430\u0442\u0440\u0430\u0442\u0430\u043c \u043f\u044f\u0442\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0451 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f 29, \u0430 \u043d\u0435 25. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u0440\u0430\u043d\u044c\u0448\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443 \u0434\u0435\u0441\u044f\u0442\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438 \u0431\u044b\u043b\u043e \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 50. \u041d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u043d\u0435\u0451, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u044c \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u0434\u0432\u0443\u0445 \u0445\u043e\u0434\u043e\u0432, \u0442\u0435\u0440\u044f\u044f 8 \u043e\u0447\u043a\u043e\u0432 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f, \u0442\u043e \u0435\u0441\u0442\u044c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0434\u043e \u043d\u0435\u0451 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0440\u0430\u0432\u043d\u044b\u043c 58.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/ff3\/7f4\/1f1\/ff37f41f11c85f7f759367fd2b33334d.png\"><\/div>\n<p>  <i>\u0414\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043e\u0436\u0438\u0434\u0430\u043b\u043e\u0441\u044c.<\/i><\/p>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u043d\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043e\u0447\u043a\u0438 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f\u043c \u0434\u043e \u044f\u0447\u0435\u0435\u043a, \u043e\u043d\u0438 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0435\u0433\u043e \u043f\u0443\u0442\u0438. \u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u0442\u0435\u0440\u044f\u0435\u0442 \u0432\u043f\u0443\u0441\u0442\u0443\u044e \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u043e\u0447\u043a\u043e\u0432. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438 \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044f\u0445 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u0443\u0442\u0438.<\/p>\n<h3>\u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0445\u043e\u0434\u043e\u0432 \u0432\u043c\u0435\u0441\u0442\u043e \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439<\/h3>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u0438\u0433\u0440\u0430\u0435\u043c \u0432 \u0438\u0433\u0440\u0443, \u043d\u0430\u043c \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0435\u0433\u043e \u043f\u0443\u0442\u0438. \u041d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0445\u043e\u0434\u043e\u0432, \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0438\u0445\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u044f \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043c\u0435\u0441\u0442\u043e \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0445\u043e\u0434\u044b.<\/p>\n<p>  \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0438\u0437\u0431\u0430\u0432\u0438\u043c\u0441\u044f \u043e\u0442 <code>UpdateDistanceLabel<\/code> \u0438 \u0435\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0432 <code>HexCell<\/code>.<\/p>\n<pre><code class=\"cs\">\tpublic int Distance { \t\tget { \t\t\treturn distance; \t\t} \t\tset { \t\t\tdistance = value; \/\/\t\t\tUpdateDistanceLabel(); \t\t} \t} \t \t\u2026 \t \/\/\tvoid UpdateDistanceLabel () { \/\/\t\tUnityEngine.UI.Text label = uiRect.GetComponent&lt;Text&gt;(); \/\/\t\tlabel.text = distance == int.MaxValue ? \"\" : distance.ToString(); \/\/\t}<\/code><\/pre>\n<p>  \u0412\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u0433\u043e \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 <code>HexCell<\/code> \u043e\u0431\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 <code>SetLabel<\/code>, \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443.<\/p>\n<pre><code class=\"cs\">\tpublic void SetLabel (string text) { \t\tUnityEngine.UI.Text label = uiRect.GetComponent&lt;Text&gt;(); \t\tlabel.text = text; \t}<\/code><\/pre>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u044d\u0442\u043e\u0442 \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432 <code>HexGrid.Search<\/code> \u043f\u0440\u0438 \u043e\u0447\u0438\u0441\u0442\u043a\u0435 \u044f\u0447\u0435\u0435\u043a. \u0427\u0442\u043e\u0431\u044b \u0441\u043a\u0440\u044b\u0442\u044c \u044f\u0447\u0435\u0439\u043a\u0438, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u043c \u0438\u043c <code>null<\/code>.<\/p>\n<pre><code class=\"cs\">\t\tfor (int i = 0; i &lt; cells.Length; i++) { \t\t\tcells[i].Distance = int.MaxValue; \t\t\tcells[i].SetLabel(null); \t\t\tcells[i].DisableHighlight(); \t\t}<\/code><\/pre>\n<p>  \u0417\u0430\u0442\u0435\u043c \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u043c \u043c\u0435\u0442\u043a\u0435 \u0441\u043e\u0441\u0435\u0434\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0435\u0433\u043e \u0445\u043e\u0434\u0430. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0445\u043e\u0434\u043e\u0432 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u0440\u043e\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0433\u043e \u043f\u0443\u0442\u0438.<\/p>\n<pre><code class=\"cs\">\t\t\t\tif (neighbor.Distance == int.MaxValue) { \t\t\t\t\tneighbor.Distance = distance; \t\t\t\t\tneighbor.SetLabel(turn.ToString()); \t\t\t\t\tneighbor.PathFrom = current; \t\t\t\t\tneighbor.SearchHeuristic = \t\t\t\t\t\tneighbor.coordinates.DistanceTo(toCell.coordinates); \t\t\t\t\tsearchFrontier.Enqueue(neighbor); \t\t\t\t} \t\t\t\telse if (distance &lt; neighbor.Distance) { \t\t\t\t\tint oldPriority = neighbor.SearchPriority; \t\t\t\t\tneighbor.Distance = distance; \t\t\t\t\tneighbor.SetLabel(turn.ToString()); \t\t\t\t\tneighbor.PathFrom = current; \t\t\t\t\tsearchFrontier.Change(neighbor, oldPriority); \t\t\t\t}<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/0d4\/6d6\/97d\/0d46d697d7c08be6d3381ce030541e4d.png\"><\/div>\n<p>  <i>\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0445\u043e\u0434\u043e\u0432, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043f\u043e \u043f\u0443\u0442\u0438.<\/i><\/p>\n<p>  <a href=\"https:\/\/catlikecoding.com\/unity\/tutorials\/hex-map\/part-17\/turn-based-movement\/turn-based-movement.unitypackage\" rel=\"nofollow\">unitypackage<\/a><\/p>\n<h2>\u041c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u044b\u0435 \u043f\u0443\u0442\u0438<\/h2>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0438\u0433\u0440\u0430\u0435\u043c \u0432 \u0438\u0433\u0440\u0443, \u043d\u0430\u0441 \u043d\u0435 \u0432\u043e\u043b\u043d\u0443\u0435\u0442, \u043a\u0430\u043a \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u0443\u0442\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u043f\u0443\u0442\u044c. \u041c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u044b\u0439 \u043f\u0443\u0442\u044c. \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0431\u044b\u0442\u044c \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0437\u0431\u0430\u0432\u0438\u043c\u0441\u044f \u043e\u0442 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0438\u0441\u043a\u0430.<\/p>\n<h3>\u0411\u0435\u0437 \u043a\u043e\u0440\u0443\u0442\u0438\u043d<\/h3>\n<p>  \u0414\u043b\u044f \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043f\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u0443. \u0411\u043e\u043b\u044c\u0448\u0435 \u043d\u0430\u043c \u044d\u0442\u043e\u0433\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0437\u0431\u0430\u0432\u0438\u043c\u0441\u044f \u043e\u0442 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 <code>StartCoroutine<\/code> \u0438 <code>StopAllCoroutines<\/code> \u0432 <code>HexGrid<\/code>. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c <code>Search<\/code> \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434.<\/p>\n<pre><code class=\"cs\">\tpublic void Load (BinaryReader reader, int header) { \/\/\t\tStopAllCoroutines(); \t\t\u2026 \t}  \tpublic void FindPath (HexCell fromCell, HexCell toCell, int speed) { \/\/\t\tStopAllCoroutines(); \/\/\t\tStartCoroutine(Search(fromCell, toCell, speed)); \t\tSearch(fromCell, toCell, speed); \t}<\/code><\/pre>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>Search<\/code> \u043a\u0430\u043a \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u0443, \u0435\u043c\u0443 \u043d\u0435 \u043d\u0443\u0436\u0435\u043d yield, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0437\u0431\u0430\u0432\u0438\u043c\u0441\u044f \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u0443\u0434\u0430\u043b\u0438\u043c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 <code>WaitForSeconds<\/code> \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u0442\u0438\u043f \u043c\u0435\u0442\u043e\u0434\u0430 \u043d\u0430 <code>void<\/code>.<\/p>\n<pre><code class=\"cs\">\tvoid Search (HexCell fromCell, HexCell toCell, int speed) { \t\t\u2026  \/\/\t\tWaitForSeconds delay = new WaitForSeconds(1 \/ 60f); \t\tfromCell.Distance = 0; \t\tsearchFrontier.Enqueue(fromCell); \t\twhile (searchFrontier.Count &gt; 0) { \/\/\t\t\tyield return delay; \t\t\tHexCell current = searchFrontier.Dequeue(); \t\t\t\u2026 \t\t} \t}<\/code><\/pre>\n<p>  <\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 74.228%;\"><iframe src=\"https:\/\/gfycat.com\/ifr\/HappygoluckyOrneryChinchilla\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  <i>\u041c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b.<\/i><\/p>\n<h3>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u043e\u0438\u0441\u043a\u0430<\/h3>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043f\u0443\u0442\u0438 \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e, \u043d\u043e \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u043e\u043d\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044e\u0442\u0441\u044f? \u041a\u043e\u0440\u043e\u0442\u043a\u0438\u0435 \u043f\u0443\u0442\u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u0447\u0442\u0438 \u0441\u0440\u0430\u0437\u0443, \u043d\u043e \u0434\u043b\u0438\u043d\u043d\u044b\u0435 \u043f\u0443\u0442\u0438 \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043a\u0430\u0440\u0442\u0430\u0445 \u043c\u043e\u0433\u0443\u0442 \u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0442\u043e\u0440\u043c\u043e\u0437\u043d\u044b\u043c\u0438.<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0437\u043c\u0435\u0440\u0438\u043c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0443\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u043f\u043e\u0438\u0441\u043a \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043f\u0443\u0442\u0438. \u0414\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u043e\u0438\u0441\u043a\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0444\u0430\u0439\u043b\u0435\u0440, \u043d\u043e \u044d\u0442\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0447\u0435\u0440\u0435\u0441\u0447\u0443\u0440 \u0438 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u0442\u0440\u0430\u0442\u044b. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e <code>Stopwatch<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0438\u043c\u0451\u043d <code>System.Diagnostics<\/code>. \u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0435\u0433\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e, \u044f \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e <code>using<\/code> \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430.<\/p>\n<p>  \u041f\u0440\u044f\u043c\u043e \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u043f\u043e\u0438\u0441\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0439 stopwatch \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0435\u0433\u043e. \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c stopwatch \u0438 \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0435\u0435 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<pre><code class=\"cs\">\tpublic void FindPath (HexCell fromCell, HexCell toCell, int speed) { \t\tSystem.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); \t\tsw.Start(); \t\tSearch(fromCell, toCell, speed); \t\tsw.Stop(); \t\tDebug.Log(sw.ElapsedMilliseconds); \t}<\/code><\/pre>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u044b\u0431\u0435\u0440\u0435\u043c \u043d\u0430\u0438\u0445\u0443\u0434\u0448\u0438\u0439 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0441\u043b\u0443\u0447\u0430\u0439 \u2014 \u043f\u043e\u0438\u0441\u043a \u0438\u0437 \u043d\u0438\u0436\u043d\u0435\u0433\u043e \u043b\u0435\u0432\u043e\u0433\u043e \u0432 \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u043f\u0440\u0430\u0432\u044b\u0439 \u0443\u0433\u043e\u043b \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043a\u0430\u0440\u0442\u044b. \u0425\u0443\u0436\u0435 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u0430\u044f \u043a\u0430\u0440\u0442\u0430, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 4 800 \u044f\u0447\u0435\u0435\u043a \u043a\u0430\u0440\u0442\u044b.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/ce1\/c03\/524\/ce1c0352479d7d8cddcff0b014291662.png\"><\/div>\n<p>  <i>\u041f\u043e\u0438\u0441\u043a \u0432 \u043d\u0430\u0438\u0445\u0443\u0434\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435.<\/i><\/p>\n<p>  \u041f\u043e\u0442\u0440\u0430\u0447\u0435\u043d\u043d\u043e\u0435 \u043d\u0430 \u043f\u043e\u0438\u0441\u043a \u0432\u0440\u0435\u043c\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u043c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 Unity \u2014 \u044d\u0442\u043e \u043d\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0439 \u043d\u0430 \u0432\u0430\u0448\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u0435\u0433\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0441\u0440\u0435\u0434\u043d\u0435\u0439 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0412 \u043c\u043e\u0451\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u0438\u0441\u043a \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u043a\u043e\u043b\u043e 45 \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434. \u042d\u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 22,22 \u043f\u0443\u0442\u044f\u043c \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443; \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u043c \u044d\u0442\u043e \u043a\u0430\u043a 22 pps (paths per second). \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043a\u0430\u0434\u0440\u043e\u0432 \u0438\u0433\u0440\u044b \u0442\u043e\u0436\u0435 \u0441\u043d\u0438\u0437\u0438\u0442\u0441\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u043d\u0430 22 fps \u0432 \u0442\u043e\u043c \u043a\u0430\u0434\u0440\u0435, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u044d\u0442\u043e\u0442 \u043f\u0443\u0442\u044c. \u0418 \u044d\u0442\u043e \u0431\u0435\u0437 \u0443\u0447\u0451\u0442\u0430 \u0432\u0441\u0435\u0439 \u0434\u0440\u0443\u0433\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u0441\u0430\u043c\u043e\u0433\u043e \u043a\u0430\u0434\u0440\u0430. \u0422\u043e \u0435\u0441\u0442\u044c \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u043a\u0430\u0434\u0440\u043e\u0432, \u043e\u043d\u0430 \u0441\u043d\u0438\u0437\u0438\u0442\u0441\u044f \u0434\u043e 20 fps.<\/p>\n<p>  \u041f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043d\u0443\u0436\u043d\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430 Unity \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u0442\u0430\u043a\u043e\u0439 \u0432\u044b\u0441\u043e\u043a\u043e\u0439, \u043a\u0430\u043a \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044e \u0442\u043e\u0442 \u0436\u0435 \u0442\u0435\u0441\u0442 \u0441\u043e \u0441\u0431\u043e\u0440\u043a\u043e\u0439, \u0442\u043e \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c \u0432\u0441\u0435\u0433\u043e 15 \u043c\u0441. \u0422\u043e \u0435\u0441\u0442\u044c 66 pps, \u0447\u0442\u043e \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043b\u0443\u0447\u0448\u0435. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u044d\u0442\u043e \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 \u043a\u0430\u0434\u0440 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043a\u0430\u0434\u0440\u043e\u0432 \u0441\u0442\u0430\u043d\u0435\u0442 \u043d\u0438\u0436\u0435 60 fps.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0413\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0436\u0443\u0440\u043d\u0430\u043b \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438?<\/b><\/p>\n<div class=\"spoiler_text\">\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Unity \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0444\u0430\u0439\u043b \u0436\u0443\u0440\u043d\u0430\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435. \u0415\u0433\u043e \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b. \u0427\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c, \u043a\u0430\u043a \u043d\u0430\u0439\u0442\u0438 \u0444\u0430\u0439\u043b\u044b \u0436\u0443\u0440\u043d\u0430\u043b\u043e\u0432 \u0432 \u0441\u0432\u043e\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0439\u0442\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e Unity \u043f\u043e <a href=\"https:\/\/docs.unity3d.com\/Manual\/LogFiles.html\">Log Files<\/a>.<\/div>\n<\/div>\n<p>  <\/p>\n<h3>\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043f\u043e\u0438\u0441\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438<\/h3>\n<p>  \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u043d\u0435\u0441\u0442\u0438 \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044e \u2014 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043f\u043e\u0438\u0441\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u043d\u0443\u0436\u0435\u043d. \u041f\u043e\u043a\u0430 \u043c\u044b \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u0443\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043a\u0430\u0434\u0440\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0437\u0430\u0436\u0430\u0442\u0430 \u043a\u043b\u0430\u0432\u0438\u0448\u0430 \u043c\u044b\u0448\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043a\u0430\u0434\u0440\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0437\u0430\u043d\u0438\u0436\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u043d\u0438\u0438. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u044d\u0442\u043e\u0433\u043e, \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u0443\u044f \u043d\u043e\u0432\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u0432 <code>HexMapEditor.HandleInput<\/code> \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u043c\u0435\u0435\u043c \u0434\u0435\u043b\u043e \u0441 \u043d\u043e\u0432\u043e\u0439 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439. \u0415\u0441\u043b\u0438 \u043d\u0435\u0442, \u0442\u043e \u0432\u0435\u0440\u043d\u044b\u043c \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0432\u0438\u0434\u0438\u043c\u044b\u0439 \u043f\u0443\u0442\u044c.<\/p>\n<pre><code class=\"cs\">\t\t\tif (editMode) { \t\t\t\tEditCells(currentCell); \t\t\t} \t\t\telse if ( \t\t\t\tInput.GetKey(KeyCode.LeftShift)  &amp;&amp; searchToCell != currentCell \t\t\t) { \t\t\t\tif (searchFromCell != currentCell) { \t\t\t\t\tif (searchFromCell) { \t\t\t\t\t\tsearchFromCell.DisableHighlight(); \t\t\t\t\t} \t\t\t\t\tsearchFromCell = currentCell; \t\t\t\t\tsearchFromCell.EnableHighlight(Color.blue); \t\t\t\t\tif (searchToCell) { \t\t\t\t\t\thexGrid.FindPath(searchFromCell, searchToCell, 24); \t\t\t\t\t} \t\t\t\t} \t\t\t} \t\t\telse if (searchFromCell &amp;&amp; searchFromCell != currentCell) { \t\t\t\tif (searchToCell != currentCell) { \t\t\t\t\tsearchToCell = currentCell; \t\t\t\t\thexGrid.FindPath(searchFromCell, searchToCell, 24); \t\t\t\t} \t\t\t}<\/code><\/pre>\n<p>  <\/p>\n<h3>\u041f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043a\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043f\u0443\u0442\u0438<\/h3>\n<p>  \u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u043a \u0445\u043e\u0434\u0430 \u2014 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0437\u0430\u0442\u0440\u0430\u0442\u043d\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043d\u0435\u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434. \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u044f\u0447\u0435\u0435\u043a \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0442\u043e\u0447\u043d\u043e \u0437\u0430\u0442\u043e\u0440\u043c\u043e\u0437\u0438\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u043a \u0432 <code>HexGrid.Search<\/code>.<\/p>\n<pre><code class=\"cs\">\t\t\t\tif (neighbor.Distance == int.MaxValue) { \t\t\t\t\tneighbor.Distance = distance; \/\/\t\t\t\t\tneighbor.SetLabel(turn.ToString()); \t\t\t\t\tneighbor.PathFrom = current; \t\t\t\t\tneighbor.SearchHeuristic = \t\t\t\t\t\tneighbor.coordinates.DistanceTo(toCell.coordinates); \t\t\t\t\tsearchFrontier.Enqueue(neighbor); \t\t\t\t} \t\t\t\telse if (distance &lt; neighbor.Distance) { \t\t\t\t\tint oldPriority = neighbor.SearchPriority; \t\t\t\t\tneighbor.Distance = distance; \/\/\t\t\t\t\tneighbor.SetLabel(turn.ToString()); \t\t\t\t\tneighbor.PathFrom = current; \t\t\t\t\tsearchFrontier.Change(neighbor, oldPriority); \t\t\t\t}<\/code><\/pre>\n<p>  \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0441\u043b\u0435 \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0445\u043e\u0434 \u0438 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043a\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u0445 \u044f\u0447\u0435\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043d\u0430 \u043f\u0443\u0442\u0438.<\/p>\n<pre><code class=\"cs\">\t\t\tif (current == toCell) { \t\t\t\tcurrent = current.PathFrom; \t\t\t\twhile (current != fromCell) { \t\t\t\t\tint turn = current.Distance \/ speed; \t\t\t\t\tcurrent.SetLabel(turn.ToString()); \t\t\t\t\tcurrent.EnableHighlight(Color.white); \t\t\t\t\tcurrent = current.PathFrom; \t\t\t\t} \t\t\t\tbreak; \t\t\t}<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/090\/f8f\/2f1\/090f8f2f121b6fafdb7b95d48fb41c8d.png\"><\/div>\n<p>  <i>\u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u043c\u0435\u0442\u043a\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u044f\u0447\u0435\u0435\u043a \u043f\u0443\u0442\u0438.<\/i><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u043a\u0438 \u044f\u0447\u0435\u0435\u043a, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0445\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439. \u041d\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u2014 \u044d\u0442\u043e \u0441\u0430\u043c\u043e\u0435 \u0432\u0430\u0436\u043d\u043e\u0435, \u0435\u0439 \u043c\u044b \u0442\u043e\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u0430\u0434\u0430\u0442\u044c \u043c\u0435\u0442\u043a\u0443. \u041c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e, \u043d\u0430\u0447\u0430\u0432 \u0446\u0438\u043a\u043b \u043f\u0443\u0442\u0438 \u0441 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438, \u0430 \u043d\u0435 \u0441 \u044f\u0447\u0435\u0439\u043a\u0438 \u043f\u0435\u0440\u0435\u0434 \u043d\u0435\u0439. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0432\u0435\u0442\u043a\u0430 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0441 \u043a\u0440\u0430\u0441\u043d\u043e\u0439 \u0441\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u043d\u0430 \u0431\u0435\u043b\u0443\u044e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0451 \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0443 \u043c\u044b \u0443\u0431\u0435\u0440\u0451\u043c \u043f\u043e\u0434 \u0446\u0438\u043a\u043b.<\/p>\n<pre><code class=\"cs\">\t\tfromCell.EnableHighlight(Color.blue); \/\/\t\ttoCell.EnableHighlight(Color.red);  \t\tfromCell.Distance = 0; \t\tsearchFrontier.Enqueue(fromCell); \t\twhile (searchFrontier.Count &gt; 0) { \t\t\tHexCell current = searchFrontier.Dequeue();  \t\t\tif (current == toCell) { \/\/\t\t\t\tcurrent = current.PathFrom; \t\t\t\twhile (current != fromCell) { \t\t\t\t\tint turn = current.Distance \/ speed; \t\t\t\t\tcurrent.SetLabel(turn.ToString()); \t\t\t\t\tcurrent.EnableHighlight(Color.white); \t\t\t\t\tcurrent = current.PathFrom; \t\t\t\t} \t\t\t\ttoCell.EnableHighlight(Color.red); \t\t\t\tbreak; \t\t\t} \t\t\t \t\t\t\u2026 \t\t}<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/dda\/273\/ea9\/dda273ea9b4aa1767db16c19abf512cd.png\"><\/div>\n<p>  <i>\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0445\u043e\u0434\u0435 \u0432\u0430\u0436\u043d\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0434\u043b\u044f \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438.<\/i><\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0438\u0445\u0443\u0434\u0448\u0435\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f \u0441\u043d\u0438\u0437\u0438\u043b\u043e\u0441\u044c \u0434\u043e 23 \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434 \u0432 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435 \u0438 \u0434\u043e 6 \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434 \u0432 \u0433\u043e\u0442\u043e\u0432\u043e\u0439 \u0441\u0431\u043e\u0440\u043a\u0435. \u042d\u0442\u043e 43 pps \u0438 166 pps \u2014 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043b\u0443\u0447\u0448\u0435.<\/p>\n<p>  <a href=\"https:\/\/catlikecoding.com\/unity\/tutorials\/hex-map\/part-17\/instant-paths\/instant-paths.unitypackage\" rel=\"nofollow\">unitypackage<\/a><\/p>\n<h2>\u0421\u0430\u043c\u044b\u0439 \u0443\u043c\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a<\/h2>\n<p>  \u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 \u043f\u043e\u0438\u0441\u043a\u0430 \u0443\u043c\u043d\u0435\u0435, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0432 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c A<sup>*<\/sup>. \u041e\u0434\u043d\u0430\u043a\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043c\u044b \u0432\u0441\u0451 \u0435\u0449\u0451 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043f\u043e\u0438\u0441\u043a \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u0412 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043c\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043e\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u044f\u0447\u0435\u0439\u043a\u0438 \u0434\u043e \u0432\u0441\u0435\u0445 \u0435\u0451 \u0441\u043e\u0441\u0435\u0434\u0435\u0439. \u042d\u0442\u043e \u0432\u0435\u0440\u043d\u043e \u0434\u043b\u044f \u044f\u0447\u0435\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043a\u0430 \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0438\u043b\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0447\u0430\u0441\u0442\u044c\u044e \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u043f\u043e\u0438\u0441\u043a\u0430. \u041d\u043e \u044f\u0447\u0435\u0439\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0436\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u044b \u0438\u0437 \u0433\u0440\u0430\u043d\u0438\u0446\u044b, \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u0443\u0436\u0435 \u043d\u0430\u0448\u043b\u0438 \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0438\u0439 \u043f\u0443\u0442\u044c \u043a \u044d\u0442\u0438\u043c \u044f\u0447\u0435\u0439\u043a\u0430\u043c. \u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f A<sup>*<\/sup> \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u044d\u0442\u0438 \u044f\u0447\u0435\u0439\u043a\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a \u0436\u0435.<\/p>\n<h3>\u0424\u0430\u0437\u0430 \u043f\u043e\u0438\u0441\u043a\u0430 \u044f\u0447\u0435\u0435\u043a<\/h3>\n<p>  \u041a\u0430\u043a \u043c\u044b \u0443\u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u044f\u0447\u0435\u0439\u043a\u0430 \u0443\u0436\u0435 \u043f\u043e\u043a\u0438\u043d\u0443\u043b\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u0443? \u041f\u043e\u043a\u0430 \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u044d\u0442\u043e\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0432 \u043a\u0430\u043a\u043e\u0439 \u0444\u0430\u0437\u0435 \u043f\u043e\u0438\u0441\u043a\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u044f\u0447\u0435\u0439\u043a\u0430. \u041e\u043d\u0430 \u0435\u0449\u0451 \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u043b\u0430\u0441\u044c \u0432 \u0433\u0440\u0430\u043d\u0438\u0446\u0435 \u0438\u043b\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043d\u0435\u0439 \u0441\u0435\u0439\u0447\u0430\u0441, \u0438\u043b\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0437\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u0435\u0439. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u044d\u0442\u043e, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0432 <code>HexCell<\/code> \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e.<\/p>\n<pre><code class=\"cs\">\tpublic int SearchPhase { get; set; }<\/code><\/pre>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, 0 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u044f\u0447\u0435\u0439\u043a\u0438 \u0435\u0449\u0451 \u043d\u0435 \u0434\u043e\u0441\u0442\u0438\u0433\u043b\u0438, 1 \u2014 \u0447\u0442\u043e \u044f\u0447\u0435\u0439\u043a\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0433\u0440\u0430\u043d\u0438\u0446\u0435 \u0441\u0435\u0439\u0447\u0430\u0441, \u0430 2 \u2014 \u0447\u0442\u043e \u043e\u043d\u0430 \u0443\u0436\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0430 \u0438\u0437 \u0433\u0440\u0430\u043d\u0438\u0446\u044b.<\/p>\n<h3>\u041f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u0435 \u0432 \u0433\u0440\u0430\u043d\u0438\u0446\u0443<\/h3>\n<p>  \u0412 <code>HexGrid.Search<\/code> \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0432\u0441\u0435 \u044f\u0447\u0435\u0439\u043a\u0438 \u043d\u0430 0 \u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c 1 \u0434\u043b\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u044b. \u0418\u043b\u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u043d\u043e\u0432\u043e\u043c \u043f\u043e\u0438\u0441\u043a\u0435. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u043d\u0435 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u0441\u0431\u0440\u043e\u0441\u043e\u043c \u044f\u0447\u0435\u0435\u043a, \u0435\u0441\u043b\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u043d\u0430 \u0434\u0432\u0430.<\/p>\n<pre><code class=\"cs\">\tint searchFrontierPhase; \t\t\t\t\t\t \t\u2026  \tvoid Search (HexCell fromCell, HexCell toCell, int speed) { \t\tsearchFrontierPhase += 2; \t\t\u2026 \t}<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0444\u0430\u0437\u0443 \u043f\u043e\u0438\u0441\u043a\u0430 \u044f\u0447\u0435\u0435\u043a \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0438\u0445 \u0432 \u0433\u0440\u0430\u043d\u0438\u0446\u0443. \u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a \u0433\u0440\u0430\u043d\u0438\u0446\u0435.<\/p>\n<pre><code class=\"cs\">\t\tfromCell.SearchPhase = searchFrontierPhase; \t\tfromCell.Distance = 0; \t\tsearchFrontier.Enqueue(fromCell);<\/code><\/pre>\n<p>  \u0410 \u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043e\u0441\u0435\u0434\u0430 \u043a \u0433\u0440\u0430\u043d\u0438\u0446\u0435.<\/p>\n<pre><code class=\"cs\">\t\t\t\tif (neighbor.Distance == int.MaxValue) { \t\t\t\t\tneighbor.SearchPhase = searchFrontierPhase; \t\t\t\t\tneighbor.Distance = distance; \t\t\t\t\tneighbor.PathFrom = current; \t\t\t\t\tneighbor.SearchHeuristic = \t\t\t\t\t\tneighbor.coordinates.DistanceTo(toCell.coordinates); \t\t\t\t\tsearchFrontier.Enqueue(neighbor); \t\t\t\t}<\/code><\/pre>\n<p>  <\/p>\n<h3>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u044b<\/h3>\n<p>  \u0414\u043e \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u044f\u0447\u0435\u0439\u043a\u0443 \u043f\u043e\u043a\u0430 \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u043b\u0438 \u043a \u0433\u0440\u0430\u043d\u0438\u0446\u0435, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0440\u0430\u0432\u043d\u043e\u0435 <code>int.MaxValue<\/code>. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0444\u0430\u0437\u0443 \u043f\u043e\u0438\u0441\u043a\u0430 \u044f\u0447\u0435\u0439\u043a\u0438 \u0441 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0433\u0440\u0430\u043d\u0438\u0446\u0435\u0439.<\/p>\n<pre><code class=\"cs\">\/\/\t\t\t\tif (neighbor.Distance == int.MaxValue) { \t\t\t\tif (neighbor.SearchPhase &lt; searchFrontierPhase) { \t\t\t\t\tneighbor.SearchPhase = searchFrontierPhase; \t\t\t\t\tneighbor.Distance = distance; \t\t\t\t\tneighbor.PathFrom = current; \t\t\t\t\tneighbor.SearchHeuristic = \t\t\t\t\t\tneighbor.coordinates.DistanceTo(toCell.coordinates); \t\t\t\t\tsearchFrontier.Enqueue(neighbor); \t\t\t\t}<\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043d\u0430\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u044f\u0447\u0435\u0435\u043a \u043f\u0435\u0440\u0435\u0434 \u043f\u043e\u0438\u0441\u043a\u043e\u043c, \u0442\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435 \u0440\u0430\u0431\u043e\u0442\u044b, \u0447\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u043e.<\/p>\n<pre><code class=\"cs\">\t\tfor (int i = 0; i &lt; cells.Length; i++) { \/\/\t\t\tcells[i].Distance = int.MaxValue; \t\t\tcells[i].SetLabel(null); \t\t\tcells[i].DisableHighlight(); \t\t}<\/code><\/pre>\n<p>  <\/p>\n<h3>\u041f\u043e\u043a\u0438\u0434\u0430\u043d\u0438\u0435 \u0433\u0440\u0430\u043d\u0438\u0446\u044b<\/h3>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u044f\u0447\u0435\u0439\u043a\u0430 \u0443\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u0433\u0440\u0430\u043d\u0438\u0446\u044b, \u043c\u044b \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u043c \u044d\u0442\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435\u043c \u0435\u0451 \u0444\u0430\u0437\u044b \u043f\u043e\u0438\u0441\u043a\u0430. \u042d\u0442\u043e \u0441\u0442\u0430\u0432\u0438\u0442 \u0435\u0451 \u0437\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0433\u0440\u0430\u043d\u0438\u0446\u0435\u0439 \u0438 \u043f\u0435\u0440\u0435\u0434 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439.<\/p>\n<pre><code class=\"cs\">\t\twhile (searchFrontier.Count &gt; 0) { \t\t\tHexCell current = searchFrontier.Dequeue(); \t\t\tcurrent.SearchPhase += 1; \t\t\t \t\t\t\u2026 \t\t}<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u044f\u0447\u0435\u0439\u043a\u0438, \u0443\u0431\u0440\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0433\u0440\u0430\u043d\u0438\u0446\u044b, \u0438\u0437\u0431\u0435\u0433\u0430\u044f \u0431\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439.<\/p>\n<pre><code class=\"cs\">\t\t\tfor (HexDirection d = HexDirection.NE; d &lt;= HexDirection.NW; d++) { \t\t\t\tHexCell neighbor = current.GetNeighbor(d); \t\t\t\tif ( \t\t\t\t\tneighbor == null || \t\t\t\t\tneighbor.SearchPhase &gt; searchFrontierPhase \t\t\t\t) { \t\t\t\t\tcontinue; \t\t\t\t} \t\t\t\t\u2026 \t\t\t}<\/code><\/pre>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043d\u0430\u0448 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0442\u0435 \u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u043d\u043e \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e. \u041d\u0430 \u043c\u043e\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u043f\u043e\u0438\u0441\u043a \u0432 \u043d\u0430\u0438\u0445\u0443\u0434\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 20 \u043c\u0441 \u0432 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435 \u0438 5 \u043c\u0441 \u0432 \u0441\u0431\u043e\u0440\u043a\u0435.<\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u044f\u0447\u0435\u0439\u043a\u0430 \u0431\u044b\u043b\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c, \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u044f \u0441\u0447\u0451\u0442\u0447\u0438\u043a \u043f\u0440\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0438 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0434\u043e \u044f\u0447\u0435\u0439\u043a\u0438. \u0420\u0430\u043d\u044c\u0448\u0435 \u043d\u0430\u0448 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432 \u0445\u0443\u0434\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u043b 28 239 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439. \u0412 \u0433\u043e\u0442\u043e\u0432\u043e\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 A<sup>*<\/sup> \u043c\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0432\u0435\u0433\u043e 14 120 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439. \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043d\u0438\u0437\u0438\u043b\u043e\u0441\u044c \u043d\u0430 50%. \u0421\u0442\u0435\u043f\u0435\u043d\u044c \u0432\u043b\u0438\u044f\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0440\u0430\u0441\u0445\u043e\u0434\u043e\u0432 \u043f\u0440\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0438 \u0437\u0430\u0442\u0440\u0430\u0442 \u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435 \u0432 \u0441\u0431\u043e\u0440\u043a\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0432\u0435\u043b\u0438\u043a\u043e, \u043d\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u043d\u043e \u0432 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435.<\/p>\n<p>  <a href=\"https:\/\/catlikecoding.com\/unity\/tutorials\/hex-map\/part-17\/smartest-search\/smartest-search.unitypackage\" rel=\"nofollow\">unitypackage<\/a><\/p>\n<h2>\u041e\u0447\u0438\u0441\u0442\u043a\u0430 \u043f\u0443\u0442\u0438<\/h2>\n<p>  \u041f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u043d\u0430\u043c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u0443\u0442\u0438. \u041f\u043e\u043a\u0430 \u043c\u044b \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u043c, \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u044f \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0438 \u0443\u0431\u0438\u0440\u0430\u044f \u043c\u0435\u0442\u043a\u0438 \u0443 \u043a\u0430\u0436\u0434\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438 \u0441\u0435\u0442\u043a\u0438. \u042d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0442\u044f\u0436\u0435\u043b\u043e\u0432\u0435\u0441\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434. \u0412 \u0438\u0434\u0435\u0430\u043b\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u044f\u0447\u0435\u0439\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f\u0432\u043b\u044f\u043b\u0438\u0441\u044c \u0447\u0430\u0441\u0442\u044c\u044e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u0443\u0442\u0438.<\/p>\n<h3>\u0422\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0438\u0441\u043a<\/h3>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0451\u043c \u0441 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0443\u0431\u0435\u0440\u0451\u043c \u043a\u043e\u0434 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u0437 <code>Search<\/code>. \u0415\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043f\u043e\u0438\u0441\u043a \u043f\u0443\u0442\u0438 \u0438 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0441 \u044d\u0442\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439.<\/p>\n<pre><code class=\"cs\">\tvoid Search (HexCell fromCell, HexCell toCell, int speed) { \t\tsearchFrontierPhase += 2; \t\tif (searchFrontier == null) { \t\t\tsearchFrontier = new HexCellPriorityQueue(); \t\t} \t\telse { \t\t\tsearchFrontier.Clear(); \t\t}  \/\/\t\tfor (int i = 0; i &lt; cells.Length; i++) { \/\/\t\t\tcells[i].SetLabel(null); \/\/\t\t\tcells[i].DisableHighlight(); \/\/\t\t} \/\/\t\tfromCell.EnableHighlight(Color.blue);  \t\tfromCell.SearchPhase = searchFrontierPhase; \t\tfromCell.Distance = 0; \t\tsearchFrontier.Enqueue(fromCell); \t\twhile (searchFrontier.Count &gt; 0) { \t\t\tHexCell current = searchFrontier.Dequeue(); \t\t\tcurrent.SearchPhase += 1;  \t\t\tif (current == toCell) { \/\/\t\t\t\twhile (current != fromCell) { \/\/\t\t\t\t\tint turn = current.Distance \/ speed; \/\/\t\t\t\t\tcurrent.SetLabel(turn.ToString()); \/\/\t\t\t\t\tcurrent.EnableHighlight(Color.white); \/\/\t\t\t\t\tcurrent = current.PathFrom; \/\/\t\t\t\t} \/\/\t\t\t\ttoCell.EnableHighlight(Color.red); \/\/\t\t\t\tbreak; \t\t\t}  \t\t\t\u2026 \t\t} \t}<\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e <code>Search<\/code> \u043d\u0430\u0448\u0451\u043b \u043f\u0443\u0442\u044c, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c boolean.<\/p>\n<pre><code class=\"cs\">\tbool Search (HexCell fromCell, HexCell toCell, int speed) { \t\tsearchFrontierPhase += 2; \t\tif (searchFrontier == null) { \t\t\tsearchFrontier = new HexCellPriorityQueue(); \t\t} \t\telse { \t\t\tsearchFrontier.Clear(); \t\t}  \t\tfromCell.SearchPhase = searchFrontierPhase; \t\tfromCell.Distance = 0; \t\tsearchFrontier.Enqueue(fromCell); \t\twhile (searchFrontier.Count &gt; 0) { \t\t\tHexCell current = searchFrontier.Dequeue(); \t\t\tcurrent.SearchPhase += 1;  \t\t\tif (current == toCell) { \t\t\t\treturn true; \t\t\t}  \t\t\t\u2026 \t\t} \t\treturn false; \t}<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0417\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u043f\u0443\u0442\u044c<\/h3>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u043f\u0443\u0442\u044c \u043d\u0430\u0439\u0434\u0435\u043d, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0435\u0433\u043e \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u043e\u0447\u0438\u0449\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0446\u0435\u0432\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 \u0438 \u0442\u043e, \u0435\u0441\u0442\u044c \u043b\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u043f\u0443\u0442\u044c.<\/p>\n<pre><code class=\"cs\">\tHexCell currentPathFrom, currentPathTo; \tbool currentPathExists; \t \t\u2026 \t \tpublic void FindPath (HexCell fromCell, HexCell toCell, int speed) { \t\tSystem.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); \t\tsw.Start(); \t\tcurrentPathFrom = fromCell; \t\tcurrentPathTo = toCell; \t\tcurrentPathExists = Search(fromCell, toCell, speed); \t\tsw.Stop(); \t\tDebug.Log(sw.ElapsedMilliseconds); \t}<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0421\u043d\u043e\u0432\u0430 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u043f\u0443\u0442\u044c<\/h3>\n<p>  \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043d\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0438\u0441\u043a\u0430, \u0447\u0442\u043e\u0431\u044b \u0441\u043d\u043e\u0432\u0430 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0443\u0442\u044c. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <code>ShowPath<\/code>. \u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u0446\u0438\u043a\u043b\u0435 \u043e\u0442 \u043a\u043e\u043d\u0446\u0430 \u0434\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0443\u0442\u0438, \u043f\u043e\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u044f \u044f\u0447\u0435\u0439\u043a\u0438 \u0438 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u044f \u0438\u0445 \u043c\u0435\u0442\u043a\u0430\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0445\u043e\u0434\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0435\u0451 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c. \u0415\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442 \u043f\u0443\u0442\u0438, \u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442 \u043a\u043e\u043d\u0446\u0435\u0432\u044b\u0435 \u0442\u043e\u0447\u043a\u0438.<\/p>\n<pre><code class=\"cs\">\tvoid ShowPath (int speed) { \t\tif (currentPathExists) { \t\t\tHexCell current = currentPathTo; \t\t\twhile (current != currentPathFrom) { \t\t\t\tint turn = current.Distance \/ speed; \t\t\t\tcurrent.SetLabel(turn.ToString()); \t\t\t\tcurrent.EnableHighlight(Color.white); \t\t\t\tcurrent = current.PathFrom; \t\t\t} \t\t} \t\tcurrentPathFrom.EnableHighlight(Color.blue); \t\tcurrentPathTo.EnableHighlight(Color.red); \t}<\/code><\/pre>\n<p>  \u0412\u044b\u0437\u043e\u0432\u0435\u043c \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0432 <code>FindPath<\/code> \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u0438\u0441\u043a\u0430.<\/p>\n<pre><code class=\"cs\">\t\tcurrentPathExists = Search(fromCell, toCell, speed); \t\tShowPath(speed);<\/code><\/pre>\n<p>  <\/p>\n<h3>\u041f\u043e\u0434\u0447\u0438\u0441\u0442\u043a\u0430<\/h3>\n<p>  \u041c\u044b \u0441\u043d\u043e\u0432\u0430 \u0432\u0438\u0434\u0438\u043c \u043f\u0443\u0442\u044c, \u043d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u043d \u043d\u0435 \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f. \u0427\u0442\u043e\u0431\u044b \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u0435\u0433\u043e, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u0435\u0442\u043e\u0434 <code>ClearPath<\/code>. \u041f\u043e \u0441\u0443\u0442\u0438 \u043e\u043d \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043f\u0438\u0435\u0439 <code>ShowPath<\/code>, \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0438 \u043c\u0435\u0442\u043a\u0438, \u0430 \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0438\u0445. \u0421\u0434\u0435\u043b\u0430\u0432 \u044d\u0442\u043e, \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0443\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438.<\/p>\n<pre><code class=\"cs\">\tvoid ClearPath () { \t\tif (currentPathExists) { \t\t\tHexCell current = currentPathTo; \t\t\twhile (current != currentPathFrom) { \t\t\t\tcurrent.SetLabel(null); \t\t\t\tcurrent.DisableHighlight(); \t\t\t\tcurrent = current.PathFrom; \t\t\t} \t\t\tcurrent.DisableHighlight(); \t\t\tcurrentPathExists = false; \t\t} \t\tcurrentPathFrom = currentPathTo = null; \t}<\/code><\/pre>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0447\u0438\u0449\u0430\u0442\u044c \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u043f\u0443\u0442\u0438, \u043f\u043e\u0441\u0435\u0449\u0430\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u044f\u0447\u0435\u0439\u043a\u0438, \u0440\u0430\u0437\u043c\u0435\u0440 \u043a\u0430\u0440\u0442\u044b \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0432\u0430\u0436\u0435\u043d. \u0412\u044b\u0437\u043e\u0432\u0435\u043c \u0435\u0433\u043e \u0432 <code>FindPath<\/code> \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430.<\/p>\n<pre><code class=\"cs\">\t\tsw.Start(); \t\tClearPath(); \t\tcurrentPathFrom = fromCell; \t\tcurrentPathTo = toCell; \t\tcurrentPathExists = Search(fromCell, toCell, speed); \t\tif (currentPathExists) { \t\t\tShowPath(speed); \t\t} \t\tsw.Stop();<\/code><\/pre>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0431\u0443\u0434\u0435\u043c \u043e\u0447\u0438\u0449\u0430\u0442\u044c \u043f\u0443\u0442\u044c \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043d\u043e\u0432\u043e\u0439 \u043a\u0430\u0440\u0442\u044b.<\/p>\n<pre><code class=\"cs\">\tpublic bool CreateMap (int x, int z) { \t\t\u2026  \t\tClearPath(); \t\tif (chunks != null) { \t\t\tfor (int i = 0; i &lt; chunks.Length; i++) { \t\t\t\tDestroy(chunks[i].gameObject); \t\t\t} \t\t}  \t\t\u2026 \t}<\/code><\/pre>\n<p>  \u0410 \u0442\u0430\u043a\u0436\u0435 \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u0434\u0440\u0443\u0433\u043e\u0439 \u043a\u0430\u0440\u0442\u044b.<\/p>\n<pre><code class=\"cs\">\tpublic void Load (BinaryReader reader, int header) { \t\tClearPath(); \t\t\u2026 \t}<\/code><\/pre>\n<p>  \u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0443\u0442\u0435\u0439 \u0441\u043d\u043e\u0432\u0430 \u043e\u0447\u0438\u0449\u0430\u0435\u0442\u0441\u044f, \u043a\u0430\u043a \u0438 \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u041d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u0438 \u0432 \u043d\u0430\u0438\u0445\u0443\u0434\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u0438\u0441\u043a\u0430 \u0432\u0440\u0435\u043c\u044f \u0441\u043d\u0438\u0437\u0438\u043b\u043e\u0441\u044c \u0434\u043e 14 \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434. \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u043e\u0435 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0431\u043e\u043b\u0435\u0435 \u0443\u043c\u043d\u043e\u0439 \u043e\u0447\u0438\u0441\u0442\u043a\u0435. \u0412\u0440\u0435\u043c\u044f \u0432 \u0441\u0431\u043e\u0440\u043a\u0435 \u0441\u043d\u0438\u0437\u0438\u043b\u043e\u0441\u044c \u0434\u043e 3 \u043c\u0441, \u0447\u0442\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 333 pps. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0438\u0441\u043a \u043f\u0443\u0442\u0435\u0439 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0442\u043e\u0447\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0434\u043e\u0431\u0438\u043b\u0438\u0441\u044c \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u0443\u0442\u0435\u0439, \u043c\u043e\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u044b\u0439 \u043a\u043e\u0434.<\/p>\n<pre><code class=\"cs\">\tpublic void FindPath (HexCell fromCell, HexCell toCell, int speed) { \/\/\t\tSystem.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); \/\/\t\tsw.Start(); \t\tClearPath(); \t\tcurrentPathFrom = fromCell; \t\tcurrentPathTo = toCell; \t\tcurrentPathExists = Search(fromCell, toCell, speed); \t\tShowPath(speed); \/\/\t\tsw.Stop(); \/\/\t\tDebug.Log(sw.ElapsedMilliseconds); \t}<\/code><\/pre>\n<p>  <a href=\"https:\/\/catlikecoding.com\/unity\/tutorials\/hex-map\/part-17\/cleaning-the-path\/cleaning-the-path.unitypackage\" rel=\"nofollow\">unitypackage<\/a><\/p>\n<h1>\u0427\u0430\u0441\u0442\u044c 18: \u043e\u0442\u0440\u044f\u0434\u044b<\/h1>\n<p>  <\/p>\n<ul>\n<li>\u0420\u0430\u0437\u043c\u0435\u0449\u0430\u0435\u043c \u043e\u0442\u0440\u044f\u0434\u044b \u043d\u0430 \u043a\u0430\u0440\u0442\u0435.<\/li>\n<li>\u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u043e\u0442\u0440\u044f\u0434\u044b.<\/li>\n<li>\u041d\u0430\u0445\u043e\u0434\u0438\u043c \u043f\u0443\u0442\u0438 \u0434\u043b\u044f \u043e\u0442\u0440\u044f\u0434\u043e\u0432.<\/li>\n<li>\u041f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c \u043e\u0442\u0440\u044f\u0434\u044b.<\/li>\n<\/ul>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c, \u043a\u0430\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043f\u043e\u0438\u0441\u043a \u043f\u0443\u0442\u0438, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043c \u043d\u0430 \u043a\u0430\u0440\u0442\u0435 \u043e\u0442\u0440\u044f\u0434\u044b.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/881\/316\/9bb\/8813169bb32795f4ea1d0c4696fddde2.jpg\"><\/div>\n<p>  <i>\u041f\u043e\u0434\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0431\u044b\u043b\u043e.<\/i><\/p>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0442\u0440\u044f\u0434\u043e\u0432<\/h2>\n<p>  \u041f\u043e\u043a\u0430 \u043c\u044b \u0438\u043c\u0435\u043b\u0438 \u0434\u0435\u043b\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u044f\u0447\u0435\u0439\u043a\u0430\u043c\u0438 \u0438 \u0438\u0445 \u043d\u0435\u043f\u043e\u0434\u0432\u0438\u0436\u043d\u044b\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438. \u041e\u0442\u0440\u044f\u0434\u044b \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u043e\u0442 \u043d\u0438\u0445 \u0442\u0435\u043c, \u0447\u0442\u043e \u043e\u043d\u0438 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b. \u041e\u0442\u0440\u044f\u0434 \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0442\u044c \u0447\u0442\u043e \u0443\u0433\u043e\u0434\u043d\u043e \u043a\u0430\u043a\u043e\u0433\u043e \u0443\u0433\u043e\u0434\u043d\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0430, \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0438\u043b\u0438 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u043d\u043e\u0433\u043e \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u0434\u043e \u0446\u0435\u043b\u043e\u0439 \u0430\u0440\u043c\u0438\u0438. \u0412 \u044d\u0442\u043e\u043c \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435 \u043c\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u043c\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u043e\u0431\u043e\u0431\u0449\u0451\u043d\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c \u043e\u0442\u0440\u044f\u0434\u0430. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0435 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0439 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0442\u0438\u043f\u043e\u0432 \u043e\u0442\u0440\u044f\u0434\u043e\u0432.<\/p>\n<h3>\u041f\u0440\u0435\u0444\u0430\u0431 \u043e\u0442\u0440\u044f\u0434\u0430<\/h3>\n<p>  \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043e\u0442\u0440\u044f\u0434\u0430\u043c\u0438 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 <code>HexUnit<\/code>. \u041f\u043e\u043a\u0430 \u043d\u0430\u0447\u043d\u0451\u043c \u0441 \u043f\u0443\u0441\u0442\u043e\u0433\u043e <code>MonoBehaviour<\/code>, \u0430 \u043f\u043e\u0437\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a \u043d\u0435\u043c\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b.<\/p>\n<pre><code class=\"cs\">using UnityEngine;  public class HexUnit : MonoBehaviour { }<\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0443\u0441\u0442\u043e\u0439 \u0438\u0433\u0440\u043e\u0432\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u044d\u0442\u0438\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u0442\u0430\u0442\u044c \u043f\u0440\u0435\u0444\u0430\u0431\u043e\u043c. \u042d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u043e\u0442\u0440\u044f\u0434\u0430.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8de\/c85\/2f2\/8dec852f21d7aaa2c3002dc119d890ef.png\"><\/div>\n<p>  \u041f\u0440\u0435\u0444\u0430\u0431 \u043e\u0442\u0440\u044f\u0434\u0430.<\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 3D-\u043c\u043e\u0434\u0435\u043b\u044c, \u0441\u0438\u043c\u0432\u043e\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0449\u0443\u044e \u043e\u0442\u0440\u044f\u0434. \u042f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043e\u0442\u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u0443\u0431, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0441\u043e\u0437\u0434\u0430\u043b \u0441\u0438\u043d\u0438\u0439 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b. \u041a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0437\u0435\u043c\u043b\u0438 \u043e\u0442\u0440\u044f\u0434\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0441\u043c\u0435\u0441\u0442\u0438\u043c \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/be6\/157\/db2\/be6157db233e9e6fc0a40eae6747c731.png\"><\/div>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/be6\/157\/db2\/be6157db233e9e6fc0a40eae6747c731.png\"><\/div>\n<p>  <i>\u0414\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442-\u043a\u0443\u0431.<\/i><\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043e\u0442\u0440\u044f\u0434\u0443 \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440, \u0447\u0442\u043e\u0431\u044b \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0435\u0433\u043e \u0431\u044b\u043b\u043e \u043b\u0435\u0433\u0447\u0435 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c. \u041d\u0430\u043c \u0432\u043f\u043e\u043b\u043d\u0435 \u043f\u043e\u0434\u043e\u0439\u0434\u0451\u0442 \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u043a\u0443\u0431\u0430, \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u0443 \u044f\u0447\u0435\u0439\u043a\u0443.<\/p>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u043e\u0442\u0440\u044f\u0434\u043e\u0432<\/h3>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u0443 \u043d\u0430\u0441 \u043f\u043e\u043a\u0430 \u043d\u0435\u0442 \u0438\u0433\u0440\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0442\u0440\u044f\u0434\u043e\u0432 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044d\u0442\u0438\u043c \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f <code>HexMapEditor<\/code>. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u043c\u0443 \u043d\u0443\u0436\u0435\u043d \u043f\u0440\u0435\u0444\u0430\u0431, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u043e\u043b\u0435 <code>HexUnit unitPrefab<\/code> \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u0435\u0433\u043e.<\/p>\n<pre><code class=\"cs\">\tpublic HexUnit unitPrefab;<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/85c\/b00\/4bd\/85cb004bd7bae06a6feaa8c93f144de9.png\"><\/div>\n<p>  <i>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0444\u0430\u0431\u0430.<\/i><\/p>\n<p>  \u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043e\u0442\u0440\u044f\u0434\u043e\u0432 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0442\u044c \u0438\u0445 \u043d\u0430 \u044f\u0447\u0435\u0439\u043a\u0435, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0435\u0439\u0441\u044f \u043f\u043e\u0434 \u043a\u0443\u0440\u0441\u043e\u0440\u043e\u043c. \u0412 <code>HandleInput<\/code> \u0435\u0441\u0442\u044c \u043a\u043e\u0434 \u0434\u043b\u044f \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438 \u043f\u0440\u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0440\u0435\u043b\u044c\u0435\u0444\u0430. \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043d \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0438 \u0434\u043b\u044f \u043e\u0442\u0440\u044f\u0434\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434.<\/p>\n<pre><code class=\"cs\">\tHexCell GetCellUnderCursor () { \t\tRay inputRay = Camera.main.ScreenPointToRay(Input.mousePosition); \t\tRaycastHit hit; \t\tif (Physics.Raycast(inputRay, out hit)) { \t\t\treturn hexGrid.GetCell(hit.point); \t\t} \t\treturn null; \t}<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0432 <code>HandleInput<\/code>, \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0432 \u0435\u0433\u043e.<\/p>\n<pre><code class=\"cs\">\tvoid HandleInput () { \/\/\t\tRay inputRay = Camera.main.ScreenPointToRay(Input.mousePosition); \/\/\t\tRaycastHit hit; \/\/\t\tif (Physics.Raycast(inputRay, out hit)) { \/\/\t\t\tHexCell currentCell = hexGrid.GetCell(hit.point);  \t\tHexCell currentCell = GetCellUnderCursor(); \t\tif (currentCell) { \t\t\t\u2026 \t\t} \t\telse { \t\t\tpreviousCell = null; \t\t} \t}<\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <code>CreateUnit<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u043e\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <code>GetCellUnderCursor<\/code>. \u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u044f\u0447\u0435\u0439\u043a\u0430, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043e\u0442\u0440\u044f\u0434.<\/p>\n<pre><code class=\"cs\">\tvoid CreateUnit () { \t\tHexCell cell = GetCellUnderCursor(); \t\tif (cell) { \t\t\tInstantiate(unitPrefab); \t\t} \t}<\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044f \u0431\u044b\u043b\u0430 \u0447\u0438\u0441\u0442\u043e\u0439, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0435\u0442\u043a\u0443 \u043a\u0430\u043a \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0438\u0433\u0440\u043e\u0432\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043e\u0442\u0440\u044f\u0434\u043e\u0432.<\/p>\n<pre><code class=\"cs\">\tvoid CreateUnit () { \t\tHexCell cell = GetCellUnderCursor(); \t\tif (cell) { \t\t\tHexUnit unit = Instantiate(unitPrefab); \t\t\tunit.transform.SetParent(hexGrid.transform, false); \t\t} \t}<\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 <code>HexMapEditor<\/code> \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0442\u0440\u044f\u0434\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043a\u043b\u0430\u0432\u0438\u0448\u0438. \u0418\u0437\u043c\u0435\u043d\u0438\u043c \u043c\u0435\u0442\u043e\u0434 <code>Update<\/code> \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0432\u044b\u0437\u044b\u0432\u0430\u043b <code>CreateUnit<\/code> \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043a\u043b\u0430\u0432\u0438\u0448\u0438 U. \u041a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 <code>HandleInput<\/code>, \u044d\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c, \u0435\u0441\u043b\u0438 \u043a\u0443\u0440\u0441\u043e\u0440 \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u0432\u0435\u0440\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 GUI. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0434\u043e\u043b\u0436\u043d\u044b \u043b\u0438 \u043c\u044b \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u0440\u0442\u0443, \u0438 \u0435\u0441\u043b\u0438 \u043d\u0435\u0442, \u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0434\u043e\u043b\u0436\u043d\u044b \u043b\u0438 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043e\u0442\u0440\u044f\u0434. \u0415\u0441\u043b\u0438 \u0434\u0430, \u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c <code>CreateUnit<\/code>.<\/p>\n<pre><code class=\"cs\">\tvoid Update () { \/\/\t\tif ( \/\/\t\t\tInput.GetMouseButton(0) &amp;&amp; \/\/\t\t\t!EventSystem.current.IsPointerOverGameObject() \/\/\t\t) { \/\/\t\t\tHandleInput(); \/\/\t\t} \/\/\t\telse { \/\/\t\t\tpreviousCell = null; \/\/\t\t}  \t\tif (!EventSystem.current.IsPointerOverGameObject()) { \t\t\tif (Input.GetMouseButton(0)) { \t\t\t\tHandleInput(); \t\t\t\treturn; \t\t\t} \t\t\tif (Input.GetKeyDown(KeyCode.U)) { \t\t\t\tCreateUnit(); \t\t\t\treturn; \t\t\t} \t\t} \t\tpreviousCell = null; \t}<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/55e\/b48\/c86\/55eb48c8601711d74720f29cfba7a4f3.png\"><\/div>\n<p>  <i>\u0421\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043e\u0442\u0440\u044f\u0434\u0430.<\/i><\/p>\n<h3>\u0420\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043e\u0442\u0440\u044f\u0434\u043e\u0432<\/h3>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0442\u0440\u044f\u0434\u044b, \u043d\u043e \u043e\u043d\u0438 \u043f\u043e\u044f\u0432\u043b\u044f\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 \u043a\u0430\u0440\u0442\u044b. \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u0449\u0430\u0442\u044c \u0438\u0445 \u0432 \u043d\u0443\u0436\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u0440\u044f\u0434\u044b \u0437\u043d\u0430\u043b\u0438 \u043e \u0441\u0432\u043e\u0435\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 <code>HexUnit<\/code> \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>Location<\/code>, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0435\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u043c\u0443\u044e \u0438\u043c\u0438 \u044f\u0447\u0435\u0439\u043a\u0443. \u041f\u0440\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u043e\u0442\u0440\u044f\u0434\u0430 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u044f\u0447\u0435\u0439\u043a\u0438.<\/p>\n<pre><code class=\"cs\">\tpublic HexCell Location { \t\tget { \t\t\treturn location; \t\t} \t\tset { \t\t\tlocation = value; \t\t\ttransform.localPosition = value.Position; \t\t} \t}  \tHexCell location;<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c <code>HexMapEditor.CreateUnit<\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u043e\u0442\u0440\u044f\u0434\u0430 \u044f\u0447\u0435\u0439\u043a\u0443 \u043f\u043e\u0434 \u043a\u0443\u0440\u0441\u043e\u0440\u043e\u043c. \u0422\u043e\u0433\u0434\u0430 \u043e\u0442\u0440\u044f\u0434\u044b \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0442\u0430\u043c, \u0433\u0434\u0435 \u0434\u043e\u043b\u0436\u043d\u044b.<\/p>\n<pre><code class=\"cs\">\tvoid CreateUnit () { \t\tHexCell cell = GetCellUnderCursor(); \t\tif (cell) { \t\t\tHexUnit unit = Instantiate(unitPrefab); \t\t\tunit.transform.SetParent(hexGrid.transform, false); \t\t\tunit.Location = cell; \t\t} \t}<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/bf6\/71f\/92d\/bf671f92d2e587bebec2bf08efafadbc.png\"><\/div>\n<p>  <i>\u0420\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u043d\u0430 \u043a\u0430\u0440\u0442\u0435 \u043e\u0442\u0440\u044f\u0434\u044b.<\/i><\/p>\n<h3>\u041e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043e\u0442\u0440\u044f\u0434\u043e\u0432<\/h3>\n<p>  \u041f\u043e\u043a\u0430 \u0432\u0441\u0435 \u043e\u0442\u0440\u044f\u0434\u044b \u0438\u043c\u0435\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0443\u044e \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u044e, \u0447\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u0427\u0442\u043e\u0431\u044b \u043e\u0436\u0438\u0432\u0438\u0442\u044c \u0438\u0445, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 <code>HexUnit<\/code> \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>Orientation<\/code>. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 float, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0435\u0435 \u043f\u043e\u0432\u043e\u0440\u043e\u0442 \u043e\u0442\u0440\u044f\u0434\u0430 \u043f\u043e \u043e\u0441\u0438 Y \u0432 \u0433\u0440\u0430\u0434\u0443\u0441\u0430\u0445. \u041f\u0440\u0438 \u0435\u0433\u043e \u0437\u0430\u0434\u0430\u043d\u0438\u0438 \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u0435\u043d\u044f\u0442\u044c \u043f\u043e\u0432\u043e\u0440\u043e\u0442 \u0441\u0430\u043c\u043e\u0433\u043e \u0438\u0433\u0440\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<pre><code class=\"cs\">\tpublic float Orientation { \t\tget { \t\t\treturn orientation; \t\t} \t\tset { \t\t\torientation = value; \t\t\ttransform.localRotation = Quaternion.Euler(0f, value, 0f); \t\t} \t}  \tfloat orientation;<\/code><\/pre>\n<p>  \u0412 <code>HexMapEditor.CreateUnit<\/code> \u043d\u0430\u0437\u043d\u0430\u0447\u0438\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u043f\u043e\u0432\u043e\u0440\u043e\u0442 \u043e\u0442 0 \u0434\u043e 360 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432.<\/p>\n<pre><code class=\"cs\">\tvoid CreateUnit () { \t\tHexCell cell = GetCellUnderCursor(); \t\tif (cell) { \t\t\tHexUnit unit = Instantiate(unitPrefab); \t\t\tunit.transform.SetParent(hexGrid.transform, false); \t\t\tunit.Location = cell; \t\t\tunit.Orientation = Random.Range(0f, 360f); \t\t} \t}<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/74f\/c4a\/8c9\/74fc4a8c943830b4abd6049889b41843.png\"><\/div>\n<p>  <i>\u0420\u0430\u0437\u043d\u044b\u0435 \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043e\u0442\u0440\u044f\u0434\u043e\u0432.<\/i><\/p>\n<h3>\u041f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u043e\u0442\u0440\u044f\u0434\u0443 \u043d\u0430 \u044f\u0447\u0435\u0439\u043a\u0443<\/h3>\n<p>  \u041e\u0442\u0440\u044f\u0434\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043d\u0435\u043f\u043b\u043e\u0445\u043e, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0435. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043a\u043e\u043f\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u0430\u043d\u043d\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0449\u0438\u0445 \u043a\u0443\u0431\u043e\u0432.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/9f8\/a68\/4b6\/9f8a684b6425be20e23ac65901bf5888.png\"><\/div>\n<p>  <i>\u041d\u0430\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430 \u043e\u0442\u0440\u044f\u0434\u044b.<\/i><\/p>\n<p>  \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0433\u0440\u044b \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0442 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043e\u0442\u0440\u044f\u0434\u043e\u0432 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435, \u0434\u0440\u0443\u0433\u0438\u0435 \u043d\u0435\u0442. \u0422\u0430\u043a \u043a\u0430\u043a \u043f\u0440\u043e\u0449\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043e\u0434\u043d\u0438\u043c \u043e\u0442\u0440\u044f\u0434\u043e\u043c \u043d\u0430 \u044f\u0447\u0435\u0439\u043a\u0443, \u044f \u0432\u044b\u0431\u0435\u0440\u0443 \u044d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043e\u0442\u0440\u044f\u0434 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0442\u0435\u043a\u0443\u0449\u0430\u044f \u044f\u0447\u0435\u0439\u043a\u0430 \u043d\u0435 \u0437\u0430\u043d\u044f\u0442\u0430. \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0443\u0437\u043d\u0430\u0442\u044c, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 <code>HexCell<\/code> \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>Unit<\/code>.<\/p>\n<pre><code class=\"cs\">\tpublic HexUnit Unit { get; set; }<\/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>HexUnit.Location<\/code>, \u0447\u0442\u043e\u0431\u044b \u044f\u0447\u0435\u0439\u043a\u0430 \u0443\u0437\u043d\u0430\u043b\u0430, \u0441\u0442\u043e\u0438\u0442 \u043b\u0438 \u043d\u0430 \u043d\u0435\u0439 \u043e\u0442\u0440\u044f\u0434.<\/p>\n<pre><code class=\"cs\">\tpublic HexCell Location { \t\tget { \t\t\treturn location; \t\t} \t\tset { \t\t\tlocation = value; \t\t\tvalue.Unit = this; \t\t\ttransform.localPosition = value.Position; \t\t} \t}<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c <code>HexMapEditor.CreateUnit<\/code> \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c, \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u0430 \u043b\u0438 \u0442\u0435\u043a\u0443\u0449\u0430\u044f \u044f\u0447\u0435\u0439\u043a\u0430.<\/p>\n<pre><code class=\"cs\">\tvoid CreateUnit () { \t\tHexCell cell = GetCellUnderCursor(); \t\tif (cell &amp;&amp; !cell.Unit) { \t\t\tHexUnit unit = Instantiate(unitPrefab); \t\t\tunit.Location = cell; \t\t\tunit.Orientation = Random.Range(0f, 360f); \t\t} \t}<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0430\u043d\u044f\u0442\u044b\u0445 \u044f\u0447\u0435\u0435\u043a<\/h3>\n<p>  \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043e\u0442\u0440\u044f\u0434\u044b \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u043d\u043e \u0432\u0441\u0451 \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c\u0441\u044f, \u0435\u0441\u043b\u0438 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0438\u0445 \u044f\u0447\u0435\u0439\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f. \u0415\u0441\u043b\u0438 \u0432\u044b\u0441\u043e\u0442\u0430 \u044f\u0447\u0435\u0439\u043a\u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f, \u0442\u043e \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0449\u0438\u0439 \u0435\u0451 \u043e\u0442\u0440\u044f\u0434 \u0438\u043b\u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0441\u0435\u0442\u044c \u043d\u0430\u0434 \u043d\u0435\u0439, \u0438\u043b\u0438 \u043f\u043e\u0433\u0440\u0443\u0437\u0438\u0442\u0441\u044f \u0432 \u043d\u0435\u0451.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/27b\/b7d\/1c1\/27bb7d1c120bc1546dfa0fd42823d66c.png\"><\/div>\n<p>  <i>\u0412\u0438\u0441\u044f\u0449\u0438\u0435 \u0438 \u0443\u0442\u043e\u043d\u0443\u0432\u0448\u0438\u0435 \u043e\u0442\u0440\u044f\u0434\u044b.<\/i><\/p>\n<p>  \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u043e\u0442\u0440\u044f\u0434\u0430 \u043f\u043e\u0441\u043b\u0435 \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043c\u0435\u0442\u043e\u0434 \u0432 <code>HexUnit<\/code>. \u041f\u043e\u043a\u0430 \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0437\u0438\u0446\u0438\u044f \u043e\u0442\u0440\u044f\u0434\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u0435\u0451 \u0437\u0430\u043d\u043e\u0432\u043e.<\/p>\n<pre><code class=\"cs\">\tpublic void ValidateLocation () { \t\ttransform.localPosition = location.Position; \t}<\/code><\/pre>\n<p>  \u041c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u043e\u0442\u0440\u044f\u0434\u0430 \u043f\u0440\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u044f\u0447\u0435\u0439\u043a\u0438, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u044b <code>Refresh<\/code>, \u0438\u043b\u0438 <code>RefreshSelfOnly<\/code> \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>HexCell<\/code>. \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0433\u0434\u0430 \u0432 \u044f\u0447\u0435\u0439\u043a\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0435\u0441\u0442\u044c \u043e\u0442\u0440\u044f\u0434.<\/p>\n<pre><code class=\"cs\">\tvoid Refresh () { \t\tif (chunk) { \t\t\tchunk.Refresh(); \t\t\t\u2026 \t\t\tif (Unit) { \t\t\t\tUnit.ValidateLocation(); \t\t\t} \t\t} \t}  \tvoid RefreshSelfOnly () { \t\tchunk.Refresh(); \t\tif (Unit) { \t\t\tUnit.ValidateLocation(); \t\t} \t}<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043e\u0442\u0440\u044f\u0434\u043e\u0432<\/h3>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0442\u0440\u044f\u0434\u043e\u0432 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0438\u0445 \u0438 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0430\u0442\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 <code>HexMapEditor<\/code> \u043c\u0435\u0442\u043e\u0434 <code>DestroyUnit<\/code>. \u041e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c, \u0435\u0441\u0442\u044c \u043b\u0438 \u0432 \u044f\u0447\u0435\u0439\u043a\u0435 \u043f\u043e\u0434 \u043a\u0443\u0440\u0441\u043e\u0440\u043e\u043c \u043e\u0442\u0440\u044f\u0434, \u0438 \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c, \u0442\u043e \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0430\u0442\u044c \u0438\u0433\u0440\u043e\u0432\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u043e\u0442\u0440\u044f\u0434\u0430.<\/p>\n<pre><code class=\"cs\">\tvoid DestroyUnit () { \t\tHexCell cell = GetCellUnderCursor(); \t\tif (cell &amp;&amp; cell.Unit) { \t\t\tDestroy(cell.Unit.gameObject); \t\t} \t}<\/code><\/pre>\n<p>  \u0423\u0447\u0442\u0438\u0442\u0435, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0434\u043e \u043e\u0442\u0440\u044f\u0434\u0430, \u043c\u044b \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u0447\u0435\u0440\u0435\u0437 \u044f\u0447\u0435\u0439\u043a\u0443. \u0414\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u043e\u0442\u0440\u044f\u0434\u043e\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0430\u0432\u0435\u0441\u0442\u0438 \u043c\u044b\u0448\u044c \u043d\u0430 \u0435\u0433\u043e \u044f\u0447\u0435\u0439\u043a\u0443. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e, \u043e\u0442\u0440\u044f\u0434\u0443 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440. \u041e\u0434\u043d\u0430\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440\u0430 \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0438\u0445 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 \u043b\u0443\u0447\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0431\u044b \u0441 \u044f\u0447\u0435\u0439\u043a\u043e\u0439 \u0437\u0430 \u043e\u0442\u0440\u044f\u0434\u043e\u043c.<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043b\u044f \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u0442\u0440\u044f\u0434\u0430 \u0432 <code>Update<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044e \u043b\u0435\u0432\u043e\u0433\u043e Shift+U.<\/p>\n<pre><code class=\"cs\">\t\t\tif (Input.GetKeyDown(KeyCode.U)) { \t\t\t\tif (Input.GetKey(KeyCode.LeftShift)) { \t\t\t\t\tDestroyUnit(); \t\t\t\t} \t\t\t\telse { \t\t\t\t\tCreateUnit(); \t\t\t\t} \t\t\t\treturn; \t\t\t}<\/code><\/pre>\n<p>  \u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0438 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0430\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u0440\u044f\u0434\u043e\u0432, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0431\u0443\u0434\u0435\u043c \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u044b\u043c\u0438 \u0438 \u043e\u0447\u0438\u0441\u0442\u0438\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u043e\u0442\u0440\u044f\u0434\u0430. \u0422\u043e \u0435\u0441\u0442\u044c \u043c\u044b \u044f\u0432\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u0447\u0438\u0441\u0442\u0438\u043c \u0441\u0441\u044b\u043b\u043a\u0443 \u044f\u0447\u0435\u0439\u043a\u0438 \u043d\u0430 \u043e\u0442\u0440\u044f\u0434. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432 <code>HexUnit<\/code> \u043c\u0435\u0442\u043e\u0434 <code>Die<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0439\u043c\u0451\u0442\u0441\u044f \u044d\u0442\u0438\u043c, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0438\u0433\u0440\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<pre><code class=\"cs\">\tpublic void Die () { \t\tlocation.Unit = null; \t\tDestroy(gameObject); \t}<\/code><\/pre>\n<p>  \u0411\u0443\u0434\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0432 <code>HexMapEditor.DestroyUnit<\/code>, \u0430 \u043d\u0435 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0430\u0442\u044c \u043e\u0442\u0440\u044f\u0434 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e.<\/p>\n<pre><code class=\"cs\">\tvoid DestroyUnit () { \t\tHexCell cell = GetCellUnderCursor(); \t\tif (cell &amp;&amp; cell.Unit) { \/\/\t\t\tDestroy(cell.Unit.gameObject); \t\t\tcell.Unit.Die(); \t\t} \t}<\/code><\/pre>\n<p>  <a href=\"https:\/\/catlikecoding.com\/unity\/tutorials\/hex-map\/part-18\/creating-units\/creating-units.unitypackage\" rel=\"nofollow\">unitypackage<\/a><\/p>\n<h2>\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043e\u0442\u0440\u044f\u0434\u043e\u0432<\/h2>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u043d\u0430 \u043a\u0430\u0440\u0442\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043e\u0442\u0440\u044f\u0434\u044b, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u0445 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0434\u043e\u0439\u0442\u0438 \u043a \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u0434\u0432\u0443\u043c\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438. \u041f\u0435\u0440\u0432\u044b\u0439 \u2014 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0442\u0440\u044f\u0434\u0430 \u043f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u044f\u0447\u0435\u0439\u043a\u0438, \u0447\u0442\u043e\u0431\u044b \u0434\u0430\u043d\u043d\u044b\u0435 \u044f\u0447\u0435\u0439\u043a\u0438 \u0438 \u043e\u0442\u0440\u044f\u0434\u0430 \u0431\u044b\u043b\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u0448\u0430\u043d\u044b. \u0412\u0442\u043e\u0440\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u2014 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u044f\u0447\u0435\u0435\u043a \u0438 \u043e\u0442\u0440\u044f\u0434\u043e\u0432 \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0425\u043e\u0442\u044f \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u0440\u043e\u0449\u0435 \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0432\u0442\u043e\u0440\u043e\u0439 \u0434\u0430\u0451\u0442 \u043d\u0430\u043c \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u0415\u0441\u043b\u0438 \u043c\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435, \u0442\u043e \u0441 \u043d\u0438\u043c\u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0449\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c.<\/p>\n<h3>\u041e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u043e\u0442\u0440\u044f\u0434\u043e\u0432<\/h3>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u043e\u0442\u0440\u044f\u0434\u044b \u0432\u043c\u0435\u0441\u0442\u0435, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0445 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c. \u041c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0432 <code>HexGrid<\/code> \u0441\u043f\u0438\u0441\u043e\u043a \u043e\u0442\u0440\u044f\u0434\u043e\u0432. \u042d\u0442\u043e\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432\u0441\u0435 \u043e\u0442\u0440\u044f\u0434\u044b \u043d\u0430 \u043a\u0430\u0440\u0442\u0435.<\/p>\n<pre><code class=\"cs\">\tList&lt;HexUnit&gt; units = new List&lt;HexUnit&gt;();<\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0438\u043b\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043d\u043e\u0432\u043e\u0439 \u043a\u0430\u0440\u0442\u044b \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0432\u0441\u0435\u0445 \u043e\u0442\u0440\u044f\u0434\u043e\u0432, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0445\u0441\u044f \u043d\u0430 \u043a\u0430\u0440\u0442\u0435. \u0427\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u0435\u0442\u043e\u0434 <code>ClearUnits<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0431\u0438\u0432\u0430\u0435\u0442 \u0432\u0441\u0435\u0445 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0438 \u043e\u0447\u0438\u0449\u0430\u0435\u0442 \u0435\u0433\u043e.<\/p>\n<pre><code class=\"cs\">\tvoid ClearUnits () { \t\tfor (int i = 0; i &lt; units.Count; i++) { \t\t\tunits[i].Die(); \t\t} \t\tunits.Clear(); \t}<\/code><\/pre>\n<p>  \u0412\u044b\u0437\u043e\u0432\u0435\u043c \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0432 <code>CreateMap<\/code> \u0438 \u0432 <code>Load<\/code>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u043f\u0443\u0442\u0438.<\/p>\n<pre><code class=\"cs\">\tpublic bool CreateMap (int x, int z) { \t\t\u2026  \t\tClearPath(); \t\tClearUnits(); \t\t\u2026 \t} \t \t\u2026 \t \tpublic void Load (BinaryReader reader, int header) { \t\tClearPath(); \t\tClearUnits(); \t\t\u2026 \t}<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0442\u0440\u044f\u0434\u043e\u0432 \u043a \u0441\u0435\u0442\u043a\u0435<\/h3>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043d\u043e\u0432\u044b\u0445 \u043e\u0442\u0440\u044f\u0434\u043e\u0432 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u0445 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434 <code>AddUnit<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u0439\u043c\u0451\u0442\u0441\u044f \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u043e\u0442\u0440\u044f\u0434\u0430 \u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0435\u0433\u043e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<pre><code class=\"cs\">\tpublic void AddUnit (HexUnit unit, HexCell location, float orientation) { \t\tunits.Add(unit); \t\tunit.transform.SetParent(transform, false); \t\tunit.Location = location; \t\tunit.Orientation = orientation; \t}<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c <code>HexMapEditor.CreatUnit<\/code> \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c <code>AddUnit<\/code> \u0441 \u043d\u043e\u0432\u044b\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u043c \u043e\u0442\u0440\u044f\u0434\u0430, \u0435\u0433\u043e \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0438 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439 \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439.<\/p>\n<pre><code class=\"cs\">\tvoid CreateUnit () { \t\tHexCell cell = GetCellUnderCursor(); \t\tif (cell &amp;&amp; !cell.Unit) { \/\/\t\t\tHexUnit unit = Instantiate(unitPrefab); \/\/\t\t\tunit.transform.SetParent(hexGrid.transform, false); \/\/\t\t\tunit.Location = cell; \/\/\t\t\tunit.Orientation = Random.Range(0f, 360f); \t\t\thexGrid.AddUnit( \t\t\t\tInstantiate(unitPrefab), cell, Random.Range(0f, 360f) \t\t\t); \t\t} \t}<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043e\u0442\u0440\u044f\u0434\u043e\u0432 \u0438\u0437 \u0441\u0435\u0442\u043a\u0438<\/h3>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043e\u0442\u0440\u044f\u0434\u0430 \u0438 \u0432 <code>HexGrid<\/code>. \u041f\u0440\u043e\u0441\u0442\u043e \u0443\u0434\u0430\u043b\u0438\u043c \u043e\u0442\u0440\u044f\u0434 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438 \u043f\u0440\u0438\u043a\u0430\u0436\u0435\u043c \u0435\u043c\u0443 \u0443\u043c\u0435\u0440\u0435\u0442\u044c.<\/p>\n<pre><code class=\"cs\">\tpublic void RemoveUnit (HexUnit unit) { \t\tunits.Remove(unit); \t\tunit.Die(); \t}<\/code><\/pre>\n<p>  \u0412\u044b\u0437\u043e\u0432\u0435\u043c \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0432 <code>HexMapEditor.DestroyUnit<\/code>, \u0432\u043c\u0435\u0441\u0442\u043e \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u0442\u0440\u044f\u0434\u0430 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e.<\/p>\n<pre><code class=\"cs\">\tvoid DestroyUnit () { \t\tHexCell cell = GetCellUnderCursor(); \t\tif (cell &amp;&amp; cell.Unit) { \/\/\t\t\tcell.Unit.Die(); \t\t\thexGrid.RemoveUnit(cell.Unit); \t\t} \t}<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043e\u0442\u0440\u044f\u0434\u043e\u0432<\/h3>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0432\u0441\u0435 \u043e\u0442\u0440\u044f\u0434\u044b \u0432\u043c\u0435\u0441\u0442\u0435, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u044f\u0447\u0435\u0439\u043a\u0438 \u043e\u043d\u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442. \u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043d\u0430\u0434\u0451\u0436\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0438\u0445 \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 <code>HexCoordinates<\/code> \u043c\u0435\u0442\u043e\u0434 <code>Save<\/code>, \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0435\u0433\u043e \u043f\u043e\u043b\u044f X \u0438 Z.<\/p>\n<pre><code class=\"cs\">using UnityEngine; using System.IO;  [System.Serializable] public struct HexCoordinates {  \t\u2026 \t \tpublic void Save (BinaryWriter writer) { \t\twriter.Write(x); \t\twriter.Write(z); \t} }<\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 <code>Save<\/code> \u0434\u043b\u044f <code>HexUnit<\/code> \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0438 \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u043e\u0442\u0440\u044f\u0434\u0430. \u042d\u0442\u043e \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0442\u0440\u044f\u0434\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442.<\/p>\n<pre><code class=\"cs\">using UnityEngine; using System.IO;  public class HexUnit : MonoBehaviour {  \t\u2026  \tpublic void Save (BinaryWriter writer) { \t\tlocation.coordinates.Save(writer); \t\twriter.Write(orientation); \t} }<\/code><\/pre>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a <code>HexGrid<\/code> \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u0442 \u043e\u0442\u0440\u044f\u0434\u044b, \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434 <code>Save<\/code> \u0437\u0430\u0439\u043c\u0451\u0442\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0442\u0440\u044f\u0434\u043e\u0432. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u043f\u0438\u0448\u0435\u043c \u043e\u0431\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0442\u0440\u044f\u0434\u043e\u0432, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u0431\u043e\u0439\u0434\u0451\u043c \u0438\u0445 \u0432\u0441\u0435 \u0432 \u0446\u0438\u043a\u043b\u0435.<\/p>\n<pre><code class=\"cs\">\tpublic void Save (BinaryWriter writer) { \t\twriter.Write(cellCountX); \t\twriter.Write(cellCountZ);  \t\tfor (int i = 0; i &lt; cells.Length; i++) { \t\t\tcells[i].Save(writer); \t\t}  \t\twriter.Write(units.Count); \t\tfor (int i = 0; i &lt; units.Count; i++) { \t\t\tunits[i].Save(writer); \t\t} \t}<\/code><\/pre>\n<p>  \u041c\u044b \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043c \u043d\u043e\u043c\u0435\u0440 \u0432\u0435\u0440\u0441\u0438\u0438 \u0432 <code>SaveLoadMenu.Save<\/code> \u0434\u043e 2. \u0421\u0442\u0430\u0440\u044b\u0439 \u043a\u043e\u0434 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0442\u0440\u044f\u0434\u043e\u0432. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u043d\u0443\u0436\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u0432\u0435\u0440\u0441\u0438\u0438, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c, \u0447\u0442\u043e \u0432 \u0444\u0430\u0439\u043b\u0435 \u0435\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0442\u0440\u044f\u0434\u043e\u0432.<\/p>\n<pre><code class=\"cs\">\tvoid Save (string path) { \t\tusing ( \t\t\tBinaryWriter writer = \t\t\tnew BinaryWriter(File.Open(path, FileMode.Create)) \t\t) { \t\t\twriter.Write(2); \t\t\thexGrid.Save(writer); \t\t} \t}<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043e\u0442\u0440\u044f\u0434\u043e\u0432<\/h3>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a <code>HexCoordinates<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439, \u0442\u043e \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043e\u0441\u043e\u0431\u043e\u0433\u043e \u0441\u043c\u044b\u0441\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0435\u043c\u0443 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <code>Load<\/code>. \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0435\u0433\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b.<\/p>\n<pre><code class=\"cs\">\tpublic static HexCoordinates Load (BinaryReader reader) { \t\tHexCoordinates c; \t\tc.x = reader.ReadInt32(); \t\tc.z = reader.ReadInt32(); \t\treturn c; \t}<\/code><\/pre>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0442\u0440\u044f\u0434\u043e\u0432 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c, \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043e\u0442\u0440\u044f\u0434\u043e\u0432, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u043e\u0442\u0440\u044f\u0434\u043e\u0432 \u0434\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b <code>HexGrid<\/code> \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u043d\u043e\u0432\u044b\u0445 \u043e\u0442\u0440\u044f\u0434\u043e\u0432 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438. \u0422\u0430\u043a \u0447\u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u043e <code>HexUnit<\/code>. \u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 <code>HexUnit.Load<\/code>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0451\u043c \u0441 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0442\u0440\u044f\u0434\u043e\u0432. \u0414\u043b\u044f \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f float \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>BinaryReader.ReadSingle<\/code>.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u0447\u0435\u043c\u0443 Single?<\/b><\/p>\n<div class=\"spoiler_text\">\u0422\u0438\u043f <code>float<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0447\u0438\u0441\u043b\u0430 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0437\u0430\u043f\u044f\u0442\u043e\u0439 \u043e\u0434\u0438\u043d\u0430\u0440\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043c\u0435\u044e\u0442 \u0434\u043b\u0438\u043d\u0443 \u0447\u0435\u0442\u044b\u0440\u0435 \u0431\u0430\u0439\u0442\u0430. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0442\u0430\u043a\u0436\u0435 \u0447\u0438\u0441\u043b\u0430 \u0434\u0432\u043e\u0439\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438, \u0437\u0430\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u043a\u0430\u043a <code>double<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043c\u0435\u044e\u0442 \u0434\u043b\u0438\u043d\u0443 \u0432\u043e\u0441\u0435\u043c\u044c \u0431\u0430\u0439\u0442\u043e\u0432. \u0412 Unity \u043e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0440\u0435\u0434\u043a\u043e.<\/div>\n<\/div>\n<p>  <\/p>\n<pre><code class=\"cs\">\tpublic static void Load (BinaryReader reader) { \t\tHexCoordinates coordinates = HexCoordinates.Load(reader); \t\tfloat orientation = reader.ReadSingle(); \t}<\/code><\/pre>\n<p>  \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u044d\u0442\u0430\u043f\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043d\u043e\u0432\u043e\u0433\u043e \u043e\u0442\u0440\u044f\u0434\u0430. \u041e\u0434\u043d\u0430\u043a\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043f\u0440\u0435\u0444\u0430\u0431 \u043e\u0442\u0440\u044f\u0434\u0430. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0430 \u043d\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0442\u044c, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 <code>HexUnit<\/code> \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434.<\/p>\n<pre><code class=\"cs\">\tpublic static HexUnit unitPrefab;<\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0437\u0430\u0434\u0430\u0442\u044c \u044d\u0442\u0443 \u0441\u0441\u044b\u043b\u043a\u0443, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0435\u0449\u0451 \u0440\u0430\u0437 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f <code>HexGrid<\/code>, \u043a\u0430\u043a \u043c\u044b \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u043b\u0438 \u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u043e\u0439 \u0448\u0443\u043c\u0430. \u041a\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u043e\u0432 \u043e\u0442\u0440\u044f\u0434\u043e\u0432, \u043c\u044b \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u0431\u043e\u043b\u0435\u0435 \u0445\u043e\u0440\u043e\u0448\u0435\u043c\u0443 \u0440\u0435\u0448\u0435\u043d\u0438\u044e.<\/p>\n<pre><code class=\"cs\">\tpublic HexUnit unitPrefab;  \t\u2026  \tvoid Awake () { \t\tHexMetrics.noiseSource = noiseSource; \t\tHexMetrics.InitializeHashGrid(seed); \t\tHexUnit.unitPrefab = unitPrefab; \t\tCreateMap(cellCountX, cellCountZ); \t}  \t\u2026  \tvoid OnEnable () { \t\tif (!HexMetrics.noiseSource) { \t\t\tHexMetrics.noiseSource = noiseSource; \t\t\tHexMetrics.InitializeHashGrid(seed); \t\t\tHexUnit.unitPrefab = unitPrefab; \t\t} \t}<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/251\/e2e\/9c0\/251e2e9c0e0f9ec8c6da0a0a7bce6f85.png\"><\/div>\n<p>  <i>\u041f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u043f\u0440\u0435\u0444\u0430\u0431 \u043e\u0442\u0440\u044f\u0434\u0430.<\/i><\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044f \u043d\u0430\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u0430 \u043f\u0440\u044f\u043c\u0430\u044f \u0441\u0441\u044b\u043b\u043a\u0430 \u0432 <code>HexMapEditor<\/code>. \u0412\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u0451 \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>HexUnit.unitPrefab<\/code>.<\/p>\n<pre><code class=\"cs\">\/\/\tpublic HexUnit unitPrefab;  \t\u2026  \tvoid CreateUnit () { \t\tHexCell cell = GetCellUnderCursor(); \t\tif (cell &amp;&amp; !cell.Unit) { \t\t\thexGrid.AddUnit( \t\t\t\tInstantiate(HexUnit.unitPrefab), cell, Random.Range(0f, 360f) \t\t\t); \t\t} \t}<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043d\u043e\u0432\u043e\u0433\u043e \u043e\u0442\u0440\u044f\u0434\u0430 \u0432 <code>HexUnit.Load<\/code>. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0435\u0433\u043e, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0438 \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u044e, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0430 \u0441\u0435\u0442\u043a\u0443. \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>HexGrid<\/code>.<\/p>\n<pre><code class=\"cs\">\tpublic static void Load (BinaryReader reader, HexGrid grid) { \t\tHexCoordinates coordinates = HexCoordinates.Load(reader); \t\tfloat orientation = reader.ReadSingle(); \t\tgrid.AddUnit( \t\t\tInstantiate(unitPrefab), grid.GetCell(coordinates), orientation \t\t); \t}<\/code><\/pre>\n<p>  \u0412 \u043a\u043e\u043d\u0446\u0435 <code>HexGrid.Load<\/code> \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0442\u0440\u044f\u0434\u043e\u0432 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0435\u0433\u043e \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0432\u0441\u0435\u0445 \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0445 \u043e\u0442\u0440\u044f\u0434\u043e\u0432, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0441\u0435\u0431\u044f \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.<\/p>\n<pre><code class=\"cs\">\tpublic void Load (BinaryReader reader, int header) { \t\t\u2026  \t\tint unitCount = reader.ReadInt32(); \t\tfor (int i = 0; i &lt; unitCount; i++) { \t\t\tHexUnit.Load(reader, this); \t\t} \t}<\/code><\/pre>\n<p>  \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u044d\u0442\u043e \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0444\u0430\u0439\u043b\u043e\u0432 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0439 \u0441 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 \u043d\u0435 \u043d\u0438\u0436\u0435 2, \u0432 \u043c\u043b\u0430\u0434\u0448\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 \u043e\u0442\u0440\u044f\u0434\u043e\u0432 \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0435\u0442.<\/p>\n<pre><code class=\"cs\">\t\tif (header &gt;= 2) { \t\t\tint unitCount = reader.ReadInt32(); \t\t\tfor (int i = 0; i &lt; unitCount; i++) { \t\t\t\tHexUnit.Load(reader, this); \t\t\t} \t\t}<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0432\u0435\u0440\u0441\u0438\u0438 2, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 <code>SaveLoadMenu.Load<\/code> \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043c \u043d\u043e\u043c\u0435\u0440 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0434\u043e 2.<\/p>\n<pre><code class=\"cs\">\tvoid Load (string path) { \t\tif (!File.Exists(path)) { \t\t\tDebug.LogError(\"File does not exist \" + path); \t\t\treturn; \t\t} \t\tusing (BinaryReader reader = new BinaryReader(File.OpenRead(path))) { \t\t\tint header = reader.ReadInt32(); \t\t\tif (header &lt;= 2) { \t\t\t\thexGrid.Load(reader, header); \t\t\t\tHexMapCamera.ValidatePosition(); \t\t\t} \t\t\telse { \t\t\t\tDebug.LogWarning(\"Unknown map format \" + header); \t\t\t} \t\t} \t}<\/code><\/pre>\n<p>  <a href=\"https:\/\/catlikecoding.com\/unity\/tutorials\/hex-map\/part-18\/saving-and-loading-units\/saving-and-loading-units.unitypackage\" rel=\"nofollow\">unitypackage<\/a><\/p>\n<h2>\u041f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043e\u0442\u0440\u044f\u0434\u043e\u0432<\/h2>\n<p>  \u041e\u0442\u0440\u044f\u0434\u044b \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0442\u044c \u0438\u0445 \u043f\u043e \u043a\u0430\u0440\u0442\u0435. \u0423 \u043d\u0430\u0441 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u043a\u043e\u0434 \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u0443\u0442\u0438, \u043d\u043e \u043f\u043e\u043a\u0430 \u043c\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0435\u0433\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0441\u0442. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0439 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 UI \u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 UI \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0442\u0440\u044f\u0434\u0430\u043c\u0438.<\/p>\n<h3>\u041f\u043e\u0434\u0447\u0438\u0441\u0442\u043a\u0430 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430 \u043a\u0430\u0440\u0442\u044b<\/h3>\n<p>  \u041f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043e\u0442\u0440\u044f\u0434\u043e\u0432 \u043f\u043e \u043f\u0443\u0442\u044f\u043c \u2014 \u044d\u0442\u043e \u0447\u0430\u0441\u0442\u044c \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0433\u043e \u0433\u0435\u0439\u043c\u043f\u043b\u0435\u044f, \u043e\u043d\u043e \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0443 \u043a\u0430\u0440\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0437\u0431\u0430\u0432\u0438\u043c\u0441\u044f \u0432 <code>HexMapEditor<\/code> \u043e\u0442 \u0432\u0441\u0435\u0433\u043e \u043a\u043e\u0434\u0430, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441 \u043f\u043e\u0438\u0441\u043a\u043e\u043c \u043f\u0443\u0442\u0438.<\/p>\n<pre><code class=\"cs\">\/\/\tHexCell previousCell, searchFromCell, searchToCell; \tHexCell previousCell; \t \t\u2026 \t \t\tvoid HandleInput () { \t\tHexCell currentCell = GetCellUnderCursor(); \t\tif (currentCell) { \t\t\tif (previousCell &amp;&amp; previousCell != currentCell) { \t\t\t\tValidateDrag(currentCell); \t\t\t} \t\t\telse { \t\t\t\tisDrag = false; \t\t\t} \t\t\tif (editMode) { \t\t\t\tEditCells(currentCell); \t\t\t} \/\/\t\t\telse if ( \/\/\t\t\t\tInput.GetKey(KeyCode.LeftShift) &amp;&amp; searchToCell != currentCell \/\/\t\t\t) { \/\/\t\t\t\tif (searchFromCell != currentCell) { \/\/\t\t\t\t\tif (searchFromCell) { \/\/\t\t\t\t\t\tsearchFromCell.DisableHighlight(); \/\/\t\t\t\t\t} \/\/\t\t\t\t\tsearchFromCell = currentCell; \/\/\t\t\t\t\tsearchFromCell.EnableHighlight(Color.blue); \/\/\t\t\t\t\tif (searchToCell) { \/\/\t\t\t\t\t\thexGrid.FindPath(searchFromCell, searchToCell, 24); \/\/\t\t\t\t\t} \/\/\t\t\t\t} \/\/\t\t\t} \/\/\t\t\telse if (searchFromCell &amp;&amp; searchFromCell != currentCell) { \/\/\t\t\t\tif (searchToCell != currentCell) { \/\/\t\t\t\t\tsearchToCell = currentCell; \/\/\t\t\t\t\thexGrid.FindPath(searchFromCell, searchToCell, 24); \/\/\t\t\t\t} \/\/\t\t\t} \t\t\tpreviousCell = currentCell; \t\t} \t\telse { \t\t\tpreviousCell = null; \t\t} \t}<\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u043e\u043b\u044f \u0434\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0436\u0438\u043c\u0430 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u043e\u0436\u0435\u043c \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0438\u043b\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 <code>HexMapEditor<\/code>. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u043c\u0435\u0442\u043a\u0430\u043c\u0438 UI.<\/p>\n<pre><code class=\"cs\">\/\/\tbool editMode; \t \t\u2026 \t \tpublic void SetEditMode (bool toggle) { \/\/\t\teditMode = toggle; \/\/\t\thexGrid.ShowUI(!toggle); \t\tenabled = toggle; \t} \t \t\u2026 \t \tvoid HandleInput () { \t\tHexCell currentCell = GetCellUnderCursor(); \t\tif (currentCell) { \t\t\tif (previousCell &amp;&amp; previousCell != currentCell) { \t\t\t\tValidateDrag(currentCell); \t\t\t} \t\t\telse { \t\t\t\tisDrag = false; \t\t\t} \/\/\t\t\tif (editMode) { \t\t\tEditCells(currentCell); \/\/\t\t\t} \t\t\tpreviousCell = currentCell; \t\t} \t\telse { \t\t\tpreviousCell = null; \t\t} \t}<\/code><\/pre>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043c\u044b \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u0440\u0442\u044b, \u0432 Awake \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440.<\/p>\n<pre><code class=\"cs\">\tvoid Awake () { \t\tterrainMaterial.DisableKeyword(\"GRID_ON\"); \t\tSetEditMode(false); \t}<\/code><\/pre>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c raycast \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u044f\u0447\u0435\u0439\u043a\u0438 \u043f\u043e\u0434 \u043a\u0443\u0440\u0441\u043e\u0440\u043e\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438 \u043f\u0440\u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u0430\u0440\u0442\u044b, \u0438 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0442\u0440\u044f\u0434\u0430\u043c\u0438. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043e\u043d \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430\u043c \u0438 \u0434\u043b\u044f \u0447\u0435\u0433\u043e-\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u043c \u043b\u043e\u0433\u0438\u043a\u0443 raycasting \u0438\u0437 <code>HexGrid<\/code> \u0432 \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <code>GetCell<\/code> \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c-\u043b\u0443\u0447\u043e\u043c.<\/p>\n<pre><code class=\"cs\">\tpublic HexCell GetCell (Ray ray) { \t\tRaycastHit hit; \t\tif (Physics.Raycast(ray, out hit)) { \t\t\treturn GetCell(hit.point); \t\t} \t\treturn null; \t}<\/code><\/pre>\n<p>  <code>HexMapEditor.GetCellUniderCursor<\/code> \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0441 \u043b\u0443\u0447\u043e\u043c \u043a\u0443\u0440\u0441\u043e\u0440\u0430.<\/p>\n<pre><code class=\"cs\">\tHexCell GetCellUnderCursor () { \t\treturn \t\t\thexGrid.GetCell(Camera.main.ScreenPointToRay(Input.mousePosition)); \t}<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0418\u0433\u0440\u043e\u0432\u043e\u0439 UI<\/h3>\n<p>  \u0414\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f UI \u0438\u0433\u0440\u043e\u0432\u043e\u0433\u043e \u0440\u0435\u0436\u0438\u043c\u0430 \u043c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043d\u043e\u0432\u044b\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c. \u041f\u043e\u043a\u0430 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0431\u043e\u0440\u043e\u043c \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435\u043c \u043e\u0442\u0440\u044f\u0434\u043e\u0432. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 <code>HexGameUI<\/code>. \u0414\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0435\u043c\u0443 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0441\u0435\u0442\u043a\u0443.<\/p>\n<pre><code class=\"cs\">using UnityEngine; using UnityEngine.EventSystems;  public class HexGameUI : MonoBehaviour {  \tpublic HexGrid grid; }<\/code><\/pre>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u044d\u0442\u043e\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043a \u043d\u043e\u0432\u043e\u043c\u0443 \u0438\u0433\u0440\u043e\u0432\u043e\u043c\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u0432 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 UI. \u041e\u043d \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u043d \u0438\u043c\u0435\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u043d\u043e \u0442\u0430\u043a \u043d\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 UI \u0434\u043b\u044f \u0438\u0433\u0440\u044b.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/515\/769\/bdd\/515769bdd0b6fbee9cb8451348595a57.png\"><\/div>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/9b3\/b7c\/0d7\/9b3b7c0d719d05862a76ba8e70409970.png\"><\/div>\n<p>  <i>\u041e\u0431\u044a\u0435\u043a\u0442 Game UI.<\/i><\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c <code>HexGameUI<\/code> \u043c\u0435\u0442\u043e\u0434 <code>SetEditMode<\/code>, \u043a\u0430\u043a \u0438 \u0432 <code>HexMapEditor<\/code>. \u0418\u0433\u0440\u043e\u0432\u043e\u0439 UI \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0432\u043a\u043b\u044e\u0447\u0435\u043d, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0437\u0434\u0435\u0441\u044c \u043d\u0443\u0436\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043c\u0435\u0442\u043a\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0438\u0433\u0440\u043e\u0432\u043e\u0439 UI \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043f\u0443\u0442\u044f\u043c\u0438.<\/p>\n<pre><code class=\"cs\">\tpublic void SetEditMode (bool toggle) { \t\tenabled = !toggle; \t\tgrid.ShowUI(!toggle); \t}<\/code><\/pre>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043c\u0435\u0442\u043e\u0434 \u0438\u0433\u0440\u043e\u0432\u043e\u0433\u043e UI \u0441 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u044f \u0440\u0435\u0436\u0438\u043c\u0430 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u042d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0437\u043d\u0430\u0447\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0438\u0433\u0440\u043e\u043a\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043e\u0431\u0430 \u043c\u0435\u0442\u043e\u0434\u0430.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/92b\/dde\/778\/92bdde778bfc97ae4b5bdc1d49a2bb6b.png\"><\/div>\n<p>  \u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0441\u043e\u0431\u044b\u0442\u0438\u044f.<\/p>\n<h3>\u041e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u044f\u0447\u0435\u0439\u043a\u0438<\/h3>\n<p>  \u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 <code>HexGameUI<\/code> \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c, \u043a\u0430\u043a\u0430\u044f \u044f\u0447\u0435\u0439\u043a\u0430 \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u0434 \u043a\u0443\u0440\u0441\u043e\u0440\u043e\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u043c\u0443 \u043f\u043e\u043b\u0435 <code>currentCell<\/code>.<\/p>\n<pre><code class=\"cs\">\tHexCell currentCell;<\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u0435\u0442\u043e\u0434 <code>UpdateCurrentCell<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <code>HexGrid.GetCell<\/code> \u0441 \u043b\u0443\u0447\u043e\u043c \u043a\u0443\u0440\u0441\u043e\u0440\u0430 \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u044f.<\/p>\n<pre><code class=\"cs\">\tvoid UpdateCurrentCell () { \t\tcurrentCell = \t\t\tgrid.GetCell(Camera.main.ScreenPointToRay(Input.mousePosition)); \t}<\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u044f\u0447\u0435\u0439\u043a\u0438 \u043d\u0430\u043c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0443\u0437\u043d\u0430\u0442\u044c, \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c \u043b\u0438 \u043e\u043d\u0430. \u0417\u0430\u0441\u0442\u0430\u0432\u0438\u043c <code>UpdateCurrentCell<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e.<\/p>\n<pre><code class=\"cs\">\tbool UpdateCurrentCell () { \t\tHexCell cell = \t\t\tgrid.GetCell(Camera.main.ScreenPointToRay(Input.mousePosition)); \t\tif (cell != currentCell) { \t\t\tcurrentCell = cell; \t\t\treturn true; \t\t} \t\treturn false; \t}<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0412\u044b\u0431\u043e\u0440 \u043e\u0442\u0440\u044f\u0434\u0430<\/h3>\n<p>  \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043e\u0442\u0440\u044f\u0434, \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0438 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u043e\u043b\u0435 <code>selectedUnit<\/code>.<\/p>\n<pre><code class=\"cs\">\tHexUnit selectedUnit;<\/code><\/pre>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0432\u044b\u0431\u043e\u0440, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u0441 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u044f\u0447\u0435\u0439\u043a\u0438. \u0415\u0441\u043b\u0438 \u0442\u0435\u043a\u0443\u0449\u0430\u044f \u044f\u0447\u0435\u0439\u043a\u0430 \u0435\u0441\u0442\u044c \u0442\u043e \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0449\u0438\u0439 \u044d\u0442\u0443 \u044f\u0447\u0435\u0439\u043a\u0443 \u043e\u0442\u0440\u044f\u0434 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u043c \u043e\u0442\u0440\u044f\u0434\u043e\u043c. \u0415\u0441\u043b\u0438 \u0432 \u044f\u0447\u0435\u0439\u043a\u0435 \u043d\u0435\u0442 \u043e\u0442\u0440\u044f\u0434\u0430, \u0442\u043e \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u043e\u0442\u0440\u044f\u0434 \u043d\u0435 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434 <code>DoSelection<\/code>.<\/p>\n<pre><code class=\"cs\">\tvoid DoSelection () { \t\tUpdateCurrentCell(); \t\tif (currentCell) { \t\t\tselectedUnit = currentCell.Unit; \t\t} \t}<\/code><\/pre>\n<p>  \u041c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0432\u044b\u0431\u043e\u0440 \u043e\u0442\u0440\u044f\u0434\u043e\u0432 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u043d\u0430\u0436\u0430\u0442\u0438\u0435\u043c \u043c\u044b\u0448\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043c\u0435\u0442\u043e\u0434 <code>Update<\/code>, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0439 \u0432\u044b\u0431\u043e\u0440 \u043f\u0440\u0438 \u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u0438 \u043a\u043d\u043e\u043f\u043a\u0438 \u043c\u044b\u0448\u0438 0. \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0435\u0433\u043e, \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0433\u0434\u0430 \u043a\u0443\u0440\u0441\u043e\u0440 \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430\u0434 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c GUI.<\/p>\n<pre><code class=\"cs\">\tvoid Update () { \t\tif (!EventSystem.current.IsPointerOverGameObject()) { \t\t\tif (Input.GetMouseButtonDown(0)) { \t\t\t\tDoSelection(); \t\t\t} \t\t} \t}<\/code><\/pre>\n<p>  \u041d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043c\u044b \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u043e\u0442\u0440\u044f\u0434\u0443 \u0437\u0430 \u0440\u0430\u0437 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043c\u044b\u0448\u0438. \u041f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043d\u0430 \u043f\u0443\u0441\u0442\u0443\u044e \u044f\u0447\u0435\u0439\u043a\u0443 \u0432\u044b\u0431\u043e\u0440 \u043b\u044e\u0431\u043e\u0433\u043e \u043e\u0442\u0440\u044f\u0434\u0430 \u0441\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f. \u041d\u043e \u043f\u043e\u043a\u0430 \u043c\u044b \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e.<\/p>\n<h3>\u041f\u043e\u0438\u0441\u043a \u043f\u0443\u0442\u0438 \u043e\u0442\u0440\u044f\u0434\u043e\u043c<\/h3>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u043e\u0442\u0440\u044f\u0434 \u0432\u044b\u0431\u0440\u0430\u043d, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043a\u0430\u043a \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u0443\u0442\u0438. \u0427\u0442\u043e\u0431\u044b \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e, \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c \u0435\u0449\u0451 \u043e\u0434\u043d\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043a\u043d\u043e\u043f\u043a\u0438 \u043c\u044b\u0448\u0438. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u043c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u0443\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u0437\u0438\u0446\u0438\u0435\u0439 \u043e\u0442\u0440\u044f\u0434\u0430 \u0438 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u044f\u0447\u0435\u0439\u043a\u043e\u0439. \u0412\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0432 <code>Update<\/code>, \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u0430, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u044b\u0431\u043e\u0440. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043e\u0442\u0440\u044f\u0434, \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <code>DoPathfinding<\/code>.<\/p>\n<pre><code class=\"cs\">\tvoid Update () { \t\tif (!EventSystem.current.IsPointerOverGameObject()) { \t\t\tif (Input.GetMouseButtonDown(0)) { \t\t\t\tDoSelection(); \t\t\t} \t\t\telse if (selectedUnit) { \t\t\t\tDoPathfinding(); \t\t\t} \t\t} \t}<\/code><\/pre>\n<p>  <code>DoPathfinding<\/code> \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u044f\u0447\u0435\u0439\u043a\u0443 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>HexGrid.FindPath<\/code>, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u0435\u0447\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430. \u041c\u044b \u0441\u043d\u043e\u0432\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u0443\u044e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c 24.<\/p>\n<pre><code class=\"cs\">\tvoid DoPathfinding () { \t\tUpdateCurrentCell(); \t\tgrid.FindPath(selectedUnit.Location, currentCell, 24); \t}<\/code><\/pre>\n<p>  \u0423\u0447\u0442\u0438\u0442\u0435, \u0447\u0442\u043e \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043f\u0443\u0442\u044c \u043d\u0435 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u044f\u0447\u0435\u0439\u043a\u0438.<\/p>\n<pre><code class=\"cs\">\tvoid DoPathfinding () { \t\tif (UpdateCurrentCell()) { \t\t\tgrid.FindPath(selectedUnit.Location, currentCell, 24); \t\t} \t}<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/39f\/8d1\/ce9\/39f8d1ce9040ae5370fd12f447ecd8e7.png\"><\/div>\n<p>  <i>\u041f\u043e\u0438\u0441\u043a \u043f\u0443\u0442\u0438 \u0434\u043b\u044f \u043e\u0442\u0440\u044f\u0434\u0430.<\/i><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u043f\u0443\u0442\u0438, \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0449\u0438\u0435\u0441\u044f \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0438 \u043a\u0443\u0440\u0441\u043e\u0440\u0430 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0431\u043e\u0440\u0430 \u043e\u0442\u0440\u044f\u0434\u0430. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043a\u0430\u043a\u043e\u0439 \u043e\u0442\u0440\u044f\u0434 \u0432\u044b\u0431\u0440\u0430\u043d. \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u0443\u0442\u0438 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0447\u0438\u0449\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0447\u0438\u0449\u0430\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0439 \u043f\u0443\u0442\u044c, \u0435\u0441\u043b\u0438 \u043a\u0443\u0440\u0441\u043e\u0440 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438 \u043a\u0430\u0440\u0442\u044b.<\/p>\n<pre><code class=\"cs\">\tvoid DoPathfinding () { \t\tif (UpdateCurrentCell()) { \t\t\tif (currentCell) { \t\t\t\tgrid.FindPath(selectedUnit.Location, currentCell, 24); \t\t\t} \t\t\telse { \t\t\t\tgrid.ClearPath(); \t\t\t} \t\t} \t}<\/code><\/pre>\n<p>  \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b <code>HexGrid.ClearPath<\/code> \u0431\u044b\u043b \u043e\u0431\u0449\u0438\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043d\u0435\u0441\u0451\u043c \u0442\u0430\u043a\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435.<\/p>\n<pre><code class=\"cs\">\tpublic void ClearPath () { \t\t\u2026 \t}<\/code><\/pre>\n<p>  \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u0431\u0443\u0434\u0435\u043c \u043e\u0447\u0438\u0449\u0430\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0439 \u043f\u0443\u0442\u044c \u043f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u043e\u0442\u0440\u044f\u0434\u0430.<\/p>\n<pre><code class=\"cs\">\tvoid DoSelection () { \t\tgrid.ClearPath(); \t\tUpdateCurrentCell(); \t\tif (currentCell) { \t\t\tselectedUnit = currentCell.Unit; \t\t} \t}<\/code><\/pre>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0441\u0442\u0430\u043d\u0435\u043c \u043e\u0447\u0438\u0449\u0430\u0442\u044c \u043f\u0443\u0442\u044c \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0440\u0435\u0436\u0438\u043c\u0430 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<pre><code class=\"cs\">\tpublic void SetEditMode (bool toggle) { \t\tenabled = !toggle; \t\tgrid.ShowUI(!toggle); \t\tgrid.ClearPath(); \t}<\/code><\/pre>\n<p>  <\/p>\n<h3>\u041f\u043e\u0438\u0441\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0445 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a<\/h3>\n<p>  \u041c\u044b \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0439\u0442\u0438 \u043f\u0443\u0442\u044c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. \u042d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e. \u041d\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u0441\u0430\u043c\u0430 \u043a\u043e\u043d\u0435\u0447\u043d\u0430\u044f \u044f\u0447\u0435\u0439\u043a\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438, \u0447\u0442\u043e \u043f\u0443\u0442\u0438 \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432 \u0441\u0435\u0431\u044f \u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u044f\u0447\u0435\u0439\u043a\u0438. \u041d\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u043e\u0442\u0440\u044f\u0434\u0430. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 <code>HexUnit<\/code> \u043c\u0435\u0442\u043e\u0434, \u0441\u043e\u043e\u0431\u0449\u0430\u044e\u0449\u0438\u0439 \u043d\u0430\u043c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u044f\u0447\u0435\u0439\u043a\u0430 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u0439 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439. \u041f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u044f\u0447\u0435\u0439\u043a\u0438 \u0438\u043c\u0438 \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f.<\/p>\n<pre><code class=\"cs\">\tpublic bool IsValidDestination (HexCell cell) { \t\treturn !cell.IsUnderwater; \t}<\/code><\/pre>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u044b \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u043b\u0438 \u0441\u0442\u043e\u044f\u0442\u044c \u0432 \u044f\u0447\u0435\u0439\u043a\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u043e\u0442\u0440\u044f\u0434\u0443. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u043d\u0435\u0447\u043d\u0430\u044f \u044f\u0447\u0435\u0439\u043a\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u0439, \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u0437\u0430\u043d\u044f\u0442\u0430.<\/p>\n<pre><code class=\"cs\">\tpublic bool IsValidDestination (HexCell cell) { \t\treturn !cell.IsUnderwater &amp;&amp; !cell.Unit; \t}<\/code><\/pre>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0432 <code>HexGameUI.DoPathfinding<\/code>, \u0447\u0442\u043e\u0431\u044b \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438.<\/p>\n<pre><code class=\"cs\">\tvoid DoPathfinding () { \t\tif (UpdateCurrentCell()) { \t\t\tif (currentCell &amp;&amp; selectedUnit.IsValidDestination(currentCell)) { \t\t\t\tgrid.FindPath(selectedUnit.Location, currentCell, 24); \t\t\t} \t\t\telse { \t\t\t\tgrid.ClearPath(); \t\t\t} \t\t} \t}<\/code><\/pre>\n<p>  <\/p>\n<h3>\u041f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043a \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0435<\/h3>\n<p>  \u0415\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0439 \u043f\u0443\u0442\u044c, \u0442\u043e \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043e\u0442\u0440\u044f\u0434 \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443. <code>HexGrid<\/code> \u0437\u043d\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c. \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u043b \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0432 \u043d\u043e\u0432\u043e\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f <code>HasPath<\/code>.<\/p>\n<pre><code class=\"cs\">\tpublic bool HasPath { \t\tget { \t\t\treturn currentPathExists; \t\t} \t}<\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043e\u0442\u0440\u044f\u0434, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 <code>HexGameUI<\/code> \u043c\u0435\u0442\u043e\u0434 <code>DoMove<\/code>. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u0434\u0430\u0447\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043e\u0442\u0440\u044f\u0434 \u0432\u044b\u0431\u0440\u0430\u043d. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c, \u0435\u0441\u0442\u044c \u043b\u0438 \u043f\u0443\u0442\u044c, \u0438 \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c, \u043c\u0435\u043d\u044f\u0442\u044c \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0442\u0440\u044f\u0434\u0430. \u041f\u043e\u043a\u0430 \u043c\u044b \u0441\u0440\u0430\u0437\u0443 \u0442\u0435\u043b\u0435\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043e\u0442\u0440\u044f\u0434 \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443. \u0412 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u043e\u0432 \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u0440\u044f\u0434 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043b \u0432\u0435\u0441\u044c \u043f\u0443\u0442\u044c.<\/p>\n<pre><code class=\"cs\">\tvoid DoMove () { \t\tif (grid.HasPath) { \t\t\tselectedUnit.Location = currentCell; \t\t\tgrid.ClearPath(); \t\t} \t}<\/code><\/pre>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u0430\u0447\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043d\u043e\u043f\u043a\u0443 \u043c\u044b\u0448\u0438 1 (\u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u0438). \u0411\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u044d\u0442\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b\u0431\u0440\u0430\u043d \u043e\u0442\u0440\u044f\u0434. \u0415\u0441\u043b\u0438 \u043a\u043d\u043e\u043f\u043a\u0430 \u043d\u0435 \u043d\u0430\u0436\u0430\u0442\u0430, \u0442\u043e \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043f\u043e\u0438\u0441\u043a \u043f\u0443\u0442\u0438.<\/p>\n<pre><code class=\"cs\">\tvoid Update () { \t\tif (!EventSystem.current.IsPointerOverGameObject()) { \t\t\tif (Input.GetMouseButtonDown(0)) { \t\t\t\tDoSelection(); \t\t\t} \t\t\telse if (selectedUnit) { \t\t\t\tif (Input.GetMouseButtonDown(1)) { \t\t\t\t\tDoMove(); \t\t\t\t} \t\t\t\telse { \t\t\t\t\tDoPathfinding(); \t\t\t\t} \t\t\t} \t\t} \t}<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0442\u044c \u043e\u0442\u0440\u044f\u0434\u044b! \u041d\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u043e\u043d\u0438 \u043e\u0442\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u0443\u0442\u044c \u043a \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c \u044f\u0447\u0435\u0439\u043a\u0430\u043c. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043a \u0442\u0435\u043c \u044f\u0447\u0435\u0439\u043a\u0430\u043c, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0440\u0430\u043d\u044c\u0448\u0435 \u0431\u044b\u043b \u043e\u0442\u0440\u044f\u0434. \u0422\u0430\u043a \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e <code>HexUnit<\/code> \u043d\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0441\u0442\u0430\u0440\u043e\u0435 \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u0440\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e. \u0427\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u043e, \u0431\u0443\u0434\u0435\u043c \u043e\u0447\u0438\u0449\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043e\u0442\u0440\u044f\u0434 \u0432 \u0435\u0433\u043e \u0441\u0442\u0430\u0440\u043e\u043c \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0438.<\/p>\n<pre><code class=\"cs\">\tpublic HexCell Location { \t\tget { \t\t\treturn location; \t\t} \t\tset { \t\t\tif (location) { \t\t\t\tlocation.Unit = null; \t\t\t} \t\t\tlocation = value; \t\t\tvalue.Unit = this; \t\t\ttransform.localPosition = value.Position; \t\t} \t}<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0418\u0437\u0431\u0435\u0433\u0430\u0435\u043c \u043e\u0442\u0440\u044f\u0434\u043e\u0432<\/h3>\n<p>  \u041f\u043e\u0438\u0441\u043a \u043f\u0443\u0442\u0438 \u0441\u0435\u0439\u0447\u0430\u0441 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432\u0435\u0440\u043d\u043e, \u0430 \u043e\u0442\u0440\u044f\u0434\u044b \u043c\u043e\u0433\u0443\u0442 \u0442\u0435\u043b\u0435\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u043a\u0430\u0440\u0442\u0435. \u0425\u043e\u0442\u044f \u043e\u043d\u0438 \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0442\u044c\u0441\u044f \u0432 \u044f\u0447\u0435\u0439\u043a\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u043e\u0442\u0440\u044f\u0434, \u043f\u043e\u043a\u0430 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043e\u0442\u0440\u044f\u0434\u044b, \u0441\u0442\u043e\u044f\u0449\u0438\u0435 \u043d\u0430 \u043f\u0443\u0442\u0438.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/519\/3d8\/7dd\/5193d87dd25bfa2fbc9e0ba26529b926.png\"><\/div>\n<p>  <i>\u041e\u0442\u0440\u044f\u0434\u044b \u043d\u0430 \u043f\u0443\u0442\u0438 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f.<\/i><\/p>\n<p>  \u041e\u0442\u0440\u044f\u0434\u044b \u043e\u0434\u043d\u043e\u0439 \u0444\u0440\u0430\u043a\u0446\u0438\u0438 \u043e\u0431\u044b\u0447\u043d\u043e \u043c\u043e\u0433\u0443\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0442\u044c\u0441\u044f \u0434\u0440\u0443\u0433 \u0447\u0435\u0440\u0435\u0437 \u0434\u0440\u0443\u0433\u0430, \u043d\u043e \u043f\u043e\u043a\u0430 \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442 \u0444\u0440\u0430\u043a\u0446\u0438\u0439. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0432\u0441\u0435 \u043e\u0442\u0440\u044f\u0434\u044b \u043d\u0435\u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c \u0438 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u043c\u0438 \u043f\u0443\u0442\u0438. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c, \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u044f \u0437\u0430\u043d\u044f\u0442\u044b\u0435 \u044f\u0447\u0435\u0439\u043a\u0438 \u0432 <code>HexGrid.Search<\/code>.<\/p>\n<pre><code class=\"cs\">\t\t\t\tif ( \t\t\t\t\tneighbor == null || \t\t\t\t\tneighbor.SearchPhase &gt; searchFrontierPhase \t\t\t\t) { \t\t\t\t\tcontinue; \t\t\t\t} \t\t\t\tif (neighbor.IsUnderwater || neighbor.Unit) { \t\t\t\t\tcontinue; \t\t\t\t}<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/f3c\/f3b\/698\/f3cf3b698191010f55c0c994d3e324d8.png\"><\/div>\n<p>  <i>\u0418\u0437\u0431\u0435\u0433\u0430\u0435\u043c \u043e\u0442\u0440\u044f\u0434\u043e\u0432.<\/i><\/p>\n<p>  <a href=\"https:\/\/catlikecoding.com\/unity\/tutorials\/hex-map\/part-18\/moving-units\/moving-units.unitypackage\" rel=\"nofollow\">unitypackage<\/a><\/p>\n<h1>\u0427\u0430\u0441\u0442\u044c 19: \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f<\/h1>\n<p>  <\/p>\n<ul>\n<li>\u041f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c \u043e\u0442\u0440\u044f\u0434\u044b \u043c\u0435\u0436\u0434\u0443 \u044f\u0447\u0435\u0439\u043a\u0430\u043c\u0438.<\/li>\n<li>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u043e\u0439\u0434\u0435\u043d\u043d\u044b\u0439 \u043f\u0443\u0442\u044c.<\/li>\n<li>\u041f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c \u043e\u0442\u0440\u044f\u0434\u044b \u043f\u043e \u043a\u0440\u0438\u0432\u044b\u043c.<\/li>\n<li>\u0417\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0442\u0440\u044f\u0434\u044b \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f.<\/li>\n<\/ul>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043c \u043e\u0442\u0440\u044f\u0434\u044b \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u0435\u043b\u0435\u043f\u043e\u0440\u0442\u0430\u0446\u0438\u0438 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u043f\u0443\u0442\u044f\u043c.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/a08\/e41\/a4f\/a08e41a4fd0e90ea26dc11f16ff518f2.jpg\"><\/div>\n<p>  <i>\u041e\u0442\u0440\u044f\u0434\u044b \u0432 \u043f\u0443\u0442\u0438.<\/i><\/p>\n<h2>\u0414\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u043f\u043e \u043f\u0443\u0442\u0438<\/h2>\n<p>  \u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043e\u0442\u0440\u044f\u0434\u044b \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f. \u0425\u043e\u0442\u044c \u043c\u044b \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0445 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a \u043f\u043e\u0438\u0441\u043a \u043f\u0443\u0442\u0438, \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u0434\u0430\u0447\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043e\u0442\u0440\u044f\u0434\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0435\u043b\u0435\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u0443\u044e \u044f\u0447\u0435\u0439\u043a\u0443. \u0427\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043b\u0438 \u043f\u043e \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u043c\u0443 \u043f\u0443\u0442\u0438, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u0443\u0442\u044c \u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438, \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u043e\u0442\u0440\u044f\u0434 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u044f\u0447\u0435\u0439\u043a\u0438 \u043a \u044f\u0447\u0435\u0439\u043a\u0435. \u0422\u0430\u043a \u043a\u0430\u043a \u0433\u043b\u044f\u0434\u044f \u043d\u0430 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u0441\u043b\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u043b\u0441\u044f \u043e\u0442\u0440\u044f\u0434, \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u043e\u0439\u0434\u0435\u043d\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c gizmos. \u041d\u043e \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0434\u0432\u0438\u043d\u0443\u0442\u044c\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443.<\/p>\n<h3>\u041e\u0448\u0438\u0431\u043a\u0430 \u0441 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430\u043c\u0438<\/h3>\n<p>  \u0418\u0437-\u0437\u0430 \u043d\u0435\u0434\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u043c\u044b \u043d\u0435\u0432\u0435\u0440\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0445\u043e\u0434, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u0430 \u044f\u0447\u0435\u0439\u043a\u0430. \u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0445\u043e\u0434 \u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043e\u0431\u0449\u0435\u0433\u043e \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043d\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043e\u0442\u0440\u044f\u0434\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/fd4\/c71\/5d5\/fd4c715d59e24b32ae039dafac302dbf.svg\" alt=\"$t = d \/ s$\" data-tex=\"inline\"><\/math>, \u0438 \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044f \u043e\u0441\u0442\u0430\u0442\u043e\u043a. \u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043a\u043e\u0433\u0434\u0430 \u0434\u043b\u044f \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u044f \u0432 \u044f\u0447\u0435\u0439\u043a\u0443 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u0442\u044c \u0440\u043e\u0432\u043d\u043e \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u043e\u0447\u043a\u0438 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u0445\u043e\u0434.<\/p>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0433\u0434\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0448\u0430\u0433 \u0441\u0442\u043e\u0438\u0442 1, \u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0440\u0430\u0432\u043d\u0430 3, \u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0442\u0440\u0438 \u044f\u0447\u0435\u0439\u043a\u0438 \u0437\u0430 \u0445\u043e\u0434. \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f\u0445 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0432\u0430 \u0448\u0430\u0433\u0430 \u0437\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0445\u043e\u0434, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u043b\u044f \u0442\u0440\u0435\u0442\u044c\u0435\u0433\u043e \u0448\u0430\u0433\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/67b\/841\/eae\/67b841eae38fb065a1bc48944b0893bb.svg\" alt=\"$t = d \/ s = 3 \/ 3 = 1$\" data-tex=\"inline\"><\/math>.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/d80\/9ec\/098\/d809ec098cac1850cf16d47ce45ed030.png\"><\/div>\n<p>  <i>\u0421\u0443\u043c\u043c\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0441 \u043d\u0435\u0432\u0435\u0440\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c\u044b\u043c\u0438 \u0445\u043e\u0434\u0430\u043c\u0438, \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c 3.<\/i><\/p>\n<p>  \u0414\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0445\u043e\u0434\u043e\u0432 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0433\u0440\u0430\u043d\u0438\u0446\u0443 \u043d\u0430 \u043e\u0434\u0438\u043d \u0448\u0430\u0433 \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0435. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e, \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435\u043c \u0445\u043e\u0434\u0430 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0432 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043d\u0430 1. \u0422\u043e\u0433\u0434\u0430 \u0445\u043e\u0434 \u0434\u043b\u044f \u0442\u0440\u0435\u0442\u044c\u0435\u0433\u043e \u0448\u0430\u0433\u0430 \u0431\u0443\u0434\u0435\u0442 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/760\/717\/c47\/760717c47119a90e773a90065ee8f602.svg\" alt=\"$t = 2 \/ 3 = 0$\" data-tex=\"inline\"><\/math><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/656\/291\/37e\/65629137e3267e033d1f5f6d3fd1f724.png\"><\/div>\n<p>  <i>\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u0445\u043e\u0434\u044b.<\/i><\/p>\n<p>  \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0438\u0437\u043c\u0435\u043d\u0438\u0432 \u0444\u043e\u0440\u043c\u0443\u043b\u0443 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u043d\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/74c\/bac\/d14\/74cbacd143cf19ed26c2a99320ea2d06.svg\" alt=\"$t = (d - 1) \/ s$\" data-tex=\"inline\"><\/math>. \u0412\u043d\u0435\u0441\u0451\u043c \u044d\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0432 <code>HexGrid.Search<\/code>.<\/p>\n<pre><code class=\"cs\">\tbool Search (HexCell fromCell, HexCell toCell, int speed) { \t\t\u2026 \t\twhile (searchFrontier.Count &gt; 0) { \t\t\t\u2026  \t\t\tint currentTurn = (current.Distance - 1) \/ speed;  \t\t\tfor (HexDirection d = HexDirection.NE; d &lt;= HexDirection.NW; d++) { \t\t\t\t\u2026  \t\t\t\tint distance = current.Distance + moveCost; \t\t\t\tint turn = (distance - 1) \/ speed; \t\t\t\tif (turn &gt; currentTurn) { \t\t\t\t\tdistance = turn * speed + moveCost; \t\t\t\t}  \t\t\t\t\u2026 \t\t\t} \t\t} \t\treturn false; \t}<\/code><\/pre>\n<p>  \u0418\u0437\u043c\u0435\u043d\u0438\u043c \u0442\u0430\u043a\u0436\u0435 \u043c\u0435\u0442\u043a\u0438 \u0445\u043e\u0434\u043e\u0432.<\/p>\n<pre><code class=\"cs\">\tvoid ShowPath (int speed) { \t\tif (currentPathExists) { \t\t\tHexCell current = currentPathTo; \t\t\twhile (current != currentPathFrom) { \t\t\t\tint turn = (current.Distance - 1) \/ speed; \t\t\t\t\u2026 \t\t\t} \t\t} \t\t\u2026 \t}<\/code><\/pre>\n<p>  \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u043f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u0445\u043e\u0434 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438 \u0440\u0430\u0432\u0435\u043d \u22121. \u042d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u0435\u0433\u043e, \u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u0438\u0441\u043a\u0430 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0438\u0441\u043f\u0440\u0430\u0432\u043d\u044b\u043c.<\/p>\n<h3>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043f\u0443\u0442\u0438<\/h3>\n<p>  \u041f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043f\u043e \u043f\u0443\u0442\u0438 \u2014 \u044d\u0442\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u043e\u0442\u0440\u044f\u0434\u0430. \u0427\u0442\u043e\u0431\u044b \u043e\u043d \u043c\u043e\u0433 \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u0435\u043c\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u043d\u0430\u0442\u044c \u043f\u0443\u0442\u044c. \u042d\u0442\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0435\u0441\u0442\u044c \u0443 <code>HexGrid<\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a \u043d\u0435\u043c\u0443 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u0443\u0442\u0438 \u0432 \u0432\u0438\u0434\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u044f\u0447\u0435\u0435\u043a. \u041e\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u0440\u0430\u0442\u044c \u0435\u0433\u043e \u0438\u0437 \u043f\u0443\u043b\u0430 \u0441\u043f\u0438\u0441\u043a\u043e\u0432 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u043f\u0443\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0435\u0441\u0442\u044c.<\/p>\n<pre><code class=\"cs\">\tpublic List&lt;HexCell&gt; GetPath () { \t\tif (!currentPathExists) { \t\t\treturn null; \t\t} \t\tList&lt;HexCell&gt; path = ListPool&lt;HexCell&gt;.Get(); \t\treturn path; \t}<\/code><\/pre>\n<p>  \u0421\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u043f\u0443\u0442\u0438 \u043e\u0442 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438 \u043a \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439, \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0443\u0442\u0438.<\/p>\n<pre><code class=\"cs\">\t\tList&lt;HexCell&gt; path = ListPool&lt;HexCell&gt;.Get(); \t\tfor (HexCell c = currentPathTo; c != currentPathFrom; c = c.PathFrom) { \t\t\tpath.Add(c); \t\t} \t\treturn path;<\/code><\/pre>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0432\u0435\u0441\u044c \u043f\u0443\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u0438 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u044f\u0447\u0435\u0439\u043a\u0443.<\/p>\n<pre><code class=\"cs\">\t\tfor (HexCell c = currentPathTo; c != currentPathFrom; c = c.PathFrom) { \t\t\tpath.Add(c); \t\t} \t\tpath.Add(currentPathFrom); \t\treturn path;<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u0443\u0442\u044c \u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0441 \u043d\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u043d\u043e \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u0432\u0435\u0440\u043d\u0451\u043c \u0441\u043f\u0438\u0441\u043e\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0448\u0451\u043b \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u043a \u043a\u043e\u043d\u0446\u0443.<\/p>\n<pre><code class=\"cs\">\t\tpath.Add(currentPathFrom); \t\tpath.Reverse(); \t\treturn path;<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0417\u0430\u043f\u0440\u043e\u0441 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f<\/h3>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 <code>HexUnit<\/code> \u043c\u0435\u0442\u043e\u0434, \u043f\u0440\u0438\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0435\u043c\u0443 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u043f\u0443\u0442\u0438. \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u043b\u0438 \u0435\u043c\u0443 \u0442\u0435\u043b\u0435\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0435. \u041c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432 \u043f\u0443\u043b, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d \u043d\u0430\u043c \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0432\u0440\u0435\u043c\u044f.<\/p>\n<pre><code class=\"cs\">using UnityEngine; using System.Collections.Generic; using System.IO;  public class HexUnit : MonoBehaviour {  \t\u2026  \tpublic void Travel (List&lt;HexCell&gt; path) { \t\tLocation = path[path.Count - 1]; \t}  \t\u2026 }<\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435, \u0438\u0437\u043c\u0435\u043d\u0438\u043c <code>HexGameUI.DoMove<\/code> \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0432\u044b\u0437\u044b\u0432\u0430\u043b \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0441 \u0442\u0435\u043a\u0443\u0449\u0438\u043c \u043f\u0443\u0442\u0451\u043c, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0434\u0430\u0432\u0430\u043b \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0442\u0440\u044f\u0434\u0430.<\/p>\n<pre><code class=\"cs\">\tvoid DoMove () { \t\tif (grid.HasPath) { \/\/\t\t\tselectedUnit.Location = currentCell; \t\t\tselectedUnit.Travel(grid.GetPath()); \t\t\tgrid.ClearPath(); \t\t} \t}<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0443\u0442\u0438<\/h3>\n<p>  \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043c\u044b \u043d\u0430\u0447\u043d\u0451\u043c \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u0440\u044f\u0434, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0447\u0442\u043e \u043f\u0443\u0442\u0438 \u0432\u0435\u0440\u043d\u044b. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u043f\u0440\u0438\u043a\u0430\u0437\u0430\u0432 <code>HexUnit<\/code> \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043f\u0443\u0442\u044c, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e gizmos.<\/p>\n<pre><code class=\"cs\">\tList&lt;HexCell&gt; pathToTravel;  \t\u2026  \tpublic void Travel (List&lt;HexCell&gt; path) { \t\tLocation = path[path.Count - 1]; \t\tpathToTravel = path; \t}<\/code><\/pre>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043c\u0435\u0442\u043e\u0434 <code>OnDrawGizmos<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043f\u0443\u0442\u044c, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0439\u0442\u0438 (\u0435\u0441\u043b\u0438 \u043e\u043d \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442). \u0415\u0441\u043b\u0438 \u043e\u0442\u0440\u044f\u0434 \u043f\u043e\u043a\u0430 \u043d\u0435 \u0434\u0432\u0438\u0433\u0430\u043b\u0441\u044f, \u043f\u0443\u0442\u044c \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0440\u0430\u0432\u0435\u043d <code>null<\/code>. \u041d\u043e \u0438\u0437-\u0437\u0430 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 Unity \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 Play \u043e\u043d \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0443\u0441\u0442\u044b\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c.<\/p>\n<pre><code class=\"cs\">\tvoid OnDrawGizmos () { \t\tif (pathToTravel == null || pathToTravel.Count == 0) { \t\t\treturn; \t\t} \t}<\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0443\u0442\u044c \u2014 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0441\u0444\u0435\u0440\u0443-\u0433\u0438\u0437\u043c\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438 \u043f\u0443\u0442\u0438. \u041d\u0430\u043c \u043f\u043e\u0434\u043e\u0439\u0434\u0451\u0442 \u0441\u0444\u0435\u0440\u0430 \u0440\u0430\u0434\u0438\u0443\u0441\u043e\u043c 2 \u0435\u0434\u0438\u043d\u0438\u0446\u044b.<\/p>\n<pre><code class=\"cs\">\tvoid OnDrawGizmos () { \t\tif (pathToTravel == null || pathToTravel.Count == 0) { \t\t\treturn; \t\t}  \t\tfor (int i = 0; i &lt; pathToTravel.Count; i++) { \t\t\tGizmos.DrawSphere(pathToTravel[i].Position, 2f); \t\t} \t}<\/code><\/pre>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u0443\u0442\u0438 \u0434\u043b\u044f \u043e\u0442\u0440\u044f\u0434\u0430, \u0442\u043e \u0441\u043c\u043e\u0436\u0435\u043c \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432\u0441\u0435 \u0435\u0433\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u043f\u0443\u0442\u0438.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/dac\/907\/a7d\/dac907a7da12a75436c7ae26956884bd.png\"><\/div>\n<p>  <i>Gizmos \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u043f\u0440\u043e\u0439\u0434\u0435\u043d\u043d\u044b\u0435 \u043f\u0443\u0442\u0438.<\/i><\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u044f\u0447\u0435\u0435\u043a, \u043d\u0430\u0440\u0438\u0441\u0443\u0435\u043c \u0432 \u0446\u0438\u043a\u043b\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0444\u0435\u0440 \u043d\u0430 \u043f\u0440\u044f\u043c\u043e\u0439 \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0438 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u044f\u0447\u0435\u0439\u043a\u0430\u043c\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438. \u0421\u0444\u0435\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u0438 \u0441 \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u043e\u043c 0.1 \u0435\u0434\u0438\u043d\u0438\u0446, \u0442\u0430\u043a \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u043f\u043e \u0434\u0435\u0441\u044f\u0442\u044c \u0441\u0444\u0435\u0440 \u043d\u0430 \u0441\u0435\u0433\u043c\u0435\u043d\u0442.<\/p>\n<pre><code class=\"cs\">\t\tfor (int i = 1; i &lt; pathToTravel.Count; i++) { \t\t\tVector3 a = pathToTravel[i - 1].Position; \t\t\tVector3 b = pathToTravel[i].Position; \t\t\tfor (float t = 0f; t &lt; 1f; t += 0.1f) { \t\t\t\tGizmos.DrawSphere(Vector3.Lerp(a, b, t), 2f); \t\t\t} \t\t}<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5c2\/46a\/11c\/5c246a11c0753d03b2572de5bfc297a4.png\"><\/div>\n<p>  <i>\u0411\u043e\u043b\u0435\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0435 \u043f\u0443\u0442\u0438.<\/i><\/p>\n<h3>\u0421\u043a\u043e\u043b\u044c\u0436\u0435\u043d\u0438\u0435 \u043f\u043e \u043f\u0443\u0442\u0438<\/h3>\n<p>  \u0422\u0435\u043c \u0436\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043e\u0442\u0440\u044f\u0434\u043e\u0432. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u0443. \u0412\u043c\u0435\u0441\u0442\u043e \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0438\u0437\u043c\u043e \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u043e\u0442\u0440\u044f\u0434\u0430. \u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u043e \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0430 0.1 \u0434\u0435\u043b\u044c\u0442\u043e\u0439 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0438 \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c yield \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u0442\u0440\u044f\u0434 \u0431\u0443\u0434\u0435\u0442 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u043e\u0434\u043d\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0437\u0430 \u043e\u0434\u043d\u0443 \u0441\u0435\u043a\u0443\u043d\u0434\u0443.<\/p>\n<pre><code class=\"cs\">using UnityEngine; using System.Collections; using System.Collections.Generic; using System.IO;  public class HexUnit : MonoBehaviour {  \t\u2026 \t \tIEnumerator TravelPath () { \t\tfor (int i = 1; i &lt; pathToTravel.Count; i++) { \t\t\tVector3 a = pathToTravel[i - 1].Position; \t\t\tVector3 b = pathToTravel[i].Position; \t\t\tfor (float t = 0f; t &lt; 1f; t += Time.deltaTime) { \t\t\t\ttransform.localPosition = Vector3.Lerp(a, b, t); \t\t\t\tyield return null; \t\t\t} \t\t} \t} \t \t\u2026 }<\/code><\/pre>\n<p>  \u041d\u0430\u0447\u043d\u0451\u043c \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u0443 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 <code>Travel<\/code>. \u041d\u043e \u043f\u0440\u0435\u0436\u0434\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0432\u0441\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b. \u0422\u0430\u043a \u043c\u044b \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u043c, \u0447\u0442\u043e \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u044f\u0442\u0441\u044f \u0434\u0432\u0435 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b, \u0438\u043d\u0430\u0447\u0435 \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u043b\u043e \u0431\u044b \u043a \u043e\u0447\u0435\u043d\u044c \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c.<\/p>\n<pre><code class=\"cs\">\tpublic void Travel (List&lt;HexCell&gt; path) { \t\tLocation = path[path.Count - 1]; \t\tpathToTravel = path; \t\tStopAllCoroutines(); \t\tStartCoroutine(TravelPath()); \t}<\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0435 \u0437\u0430 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u2014 \u044d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e. \u0418\u0433\u0440\u043e\u043a \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0438\u0433\u0440\u044b \u043d\u0435 \u0437\u0430\u0445\u043e\u0447\u0435\u0442 \u0436\u0434\u0430\u0442\u044c \u0442\u0430\u043a \u0434\u043e\u043b\u0433\u043e. \u041c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043e\u0442\u0440\u044f\u0434\u0430 \u043e\u043f\u0446\u0438\u0435\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438, \u043d\u043e \u043f\u043e\u043a\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443. \u042f \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u043b \u0435\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 4 \u044f\u0447\u0435\u0439\u043a\u0438 \u0437\u0430 \u0441\u0435\u043a\u0443\u043d\u0434\u0443; \u044d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e, \u043d\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442.<\/p>\n<pre><code class=\"cs\">\tconst float travelSpeed = 4f;  \t\u2026  \tIEnumerator TravelPath () { \t\tfor (int i = 1; i &lt; pathToTravel.Count; i++) { \t\t\tVector3 a = pathToTravel[i - 1].Position; \t\t\tVector3 b = pathToTravel[i].Position; \t\t\tfor (float t = 0f; t &lt; 1f; t += Time.deltaTime * travelSpeed) { \t\t\t\ttransform.localPosition = Vector3.Lerp(a, b, t); \t\t\t\tyield return null; \t\t\t} \t\t} \t}<\/code><\/pre>\n<p>  \u0422\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0443\u0442\u0435\u0439 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u0440\u044f\u0434\u043e\u0432. \u0421 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0438\u0433\u0440\u043e\u0432\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0435\u043b\u0435\u043f\u043e\u0440\u0442\u0430\u0446\u0438\u0435\u0439, \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u0435. \u041e\u0442\u0440\u044f\u0434\u044b \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442 \u043a\u043e\u043d\u0435\u0447\u043d\u0443\u044e \u044f\u0447\u0435\u0439\u043a\u0443. \u041c\u043e\u0436\u043d\u043e \u0434\u0430\u0436\u0435 \u043d\u0430\u0439\u0442\u0438 \u043f\u0443\u0442\u0438 \u0438 \u043d\u0430\u0447\u0430\u0442\u044c \u043d\u043e\u0432\u043e\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435, \u043f\u043e\u043a\u0430 \u043e\u043d\u0438 \u0435\u0449\u0451 \u043d\u0435 \u043f\u0440\u0438\u0431\u044b\u043b\u0438. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u043e\u043d\u0438 \u0442\u0435\u043b\u0435\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043a \u043d\u0430\u0447\u0430\u043b\u0443 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0443\u0442\u0438. \u042d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c, \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0432 \u043e\u0442\u0440\u044f\u0434\u044b \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u0432\u0435\u0441\u044c UI, \u043f\u043e\u043a\u0430 \u043e\u043d\u0438 \u0434\u0432\u0438\u0433\u0430\u044e\u0442\u0441\u044f, \u043d\u043e \u0442\u0430\u043a\u0430\u044f \u0431\u044b\u0441\u0442\u0440\u0430\u044f \u0440\u0435\u0430\u043a\u0446\u0438\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0443\u0434\u043e\u0431\u043d\u0430 \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0439.<\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 57.6934%;\"><iframe src=\"https:\/\/gfycat.com\/ifr\/UnfinishedLawfulLeopardseal\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  \u041f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u043e\u0442\u0440\u044f\u0434\u044b.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0410 \u043a\u0430\u043a \u043d\u0430\u0441\u0447\u0451\u0442 \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u0432 \u0432\u044b\u0441\u043e\u0442\u0430\u0445?<\/b><\/p>\n<div class=\"spoiler_text\">\u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u044e \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u0437\u0438\u0446\u0438\u044f\u043c\u0438 \u044f\u0447\u0435\u0435\u043a, \u043c\u044b \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u0438\u0440\u0443\u0435\u043c \u0438 \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u043e\u0442\u0440\u044f\u0434\u0430. \u0422\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0439 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0438, \u043f\u0440\u0438 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0438 \u043e\u0442\u0440\u044f\u0434 \u043c\u043e\u0436\u0435\u0442 \u0432\u0438\u0441\u0435\u0442\u044c \u043d\u0430\u0434 \u0440\u0435\u043b\u044c\u0435\u0444\u043e\u043c \u0438\u043b\u0438 \u0443\u0442\u043e\u043f\u0430\u0442\u044c \u0432 \u043d\u0451\u043c. \u0422\u0430\u043a \u043a\u0430\u043a \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u0431\u044b\u0441\u0442\u0440\u0430 \u0438 \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u0442\u0441\u044f \u0438\u0437\u0434\u0430\u043b\u0435\u043a\u0430, \u044d\u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0437\u0430\u043c\u0435\u0442\u043d\u043e. \u0418\u0433\u0440\u043e\u043a\u0438 \u0437\u0430\u043d\u044f\u0442\u044b \u0438\u0433\u0440\u043e\u0439, \u0430 \u043d\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043d\u0438\u0435\u043c \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u0440\u044f\u0434\u043e\u0432. \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0433\u0440\u044b \u0441 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0439 \u0432\u044b\u0441\u043e\u0442\u043e\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 Endless Legend, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043e\u0442\u0440\u044f\u0434\u044b \u043d\u0430\u043c \u0442\u043e\u0436\u0435 \u0432\u0438\u0441\u044f\u0442 \u0438\u043b\u0438 \u0443\u0442\u043e\u043f\u0430\u044e\u0442 \u0432 \u0440\u0435\u043b\u044c\u0435\u0444\u0435. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0438\u0433\u0440\u044b, \u0442\u043e \u043d\u0430\u0441 \u0438 \u043f\u043e\u0434\u0430\u0432\u043d\u043e.<\/div>\n<\/div>\n<p>  <\/p>\n<h3>\u041f\u043e\u0437\u0438\u0446\u0438\u044f \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438<\/h3>\n<p>  \u041e\u0434\u0438\u043d \u0438\u0437 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432 \u043a\u043e\u0440\u0443\u0442\u0438\u043d \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u043d\u0438 \u043d\u0435 \u00ab\u0432\u044b\u0436\u0438\u0432\u0430\u044e\u0442\u00bb \u043f\u0440\u0438 \u0440\u0435\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 Play. \u0425\u043e\u0442\u044c \u0438\u0433\u0440\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u0435\u0440\u043d\u043e, \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043e\u0442\u0440\u044f\u0434\u044b \u0437\u0430\u0441\u0442\u0440\u044f\u043d\u0443\u0442 \u0433\u0434\u0435-\u043d\u0438\u0431\u0443\u0434\u044c \u043d\u0430 \u0441\u0432\u043e\u0451\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c \u043f\u0443\u0442\u0438, \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0440\u0435\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u0438 \u0435\u0449\u0451 \u0434\u0432\u0438\u0436\u0443\u0442\u0441\u044f. \u0427\u0442\u043e\u0431\u044b \u0441\u043c\u044f\u0433\u0447\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043e\u0442\u0440\u044f\u0434\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u0432 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044f \u0438\u0445 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0432 <code>OnEnable<\/code>.<\/p>\n<pre><code class=\"cs\">\tvoid OnEnable () { \t\tif (location) { \t\t\ttransform.localPosition = location.Position; \t\t} \t}<\/code><\/pre>\n<p>  <a href=\"https:\/\/catlikecoding.com\/unity\/tutorials\/hex-map\/part-19\/traveling-a-path\/traveling-a-path.unitypackage\" rel=\"nofollow\">unitypackage<\/a><\/p>\n<h2>\u041f\u043b\u0430\u0432\u043d\u043e\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435<\/h2>\n<p>  \u0414\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u043e\u0442 \u0446\u0435\u043d\u0442\u0440\u0430 \u043a \u0446\u0435\u043d\u0442\u0440\u0443 \u044f\u0447\u0435\u0439\u043a\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0441\u0442\u0438\u0447\u043d\u043e \u0438 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0440\u0435\u0437\u043a\u0438\u0435 \u0441\u043c\u0435\u043d\u044b \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u043c\u043d\u043e\u0433\u0438\u0445 \u0438\u0433\u0440 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u043d\u043e \u043d\u0435\u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u043e, \u0435\u0441\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0445\u043e\u0442\u044f \u0431\u044b \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0441\u0442\u0438\u0447\u043d\u043e\u0435 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u0435\u0435 \u043e\u0440\u0433\u0430\u043d\u0438\u0447\u043d\u044b\u043c.<\/p>\n<h3>\u0414\u0432\u0438\u0433\u0430\u0435\u043c\u0441\u044f \u043e\u0442 \u0440\u0435\u0431\u0440\u0430 \u043a \u0440\u0435\u0431\u0440\u0443<\/h3>\n<p>  \u041e\u0442\u0440\u044f\u0434 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0441\u0432\u043e\u0451 \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u0435 \u0441 \u0446\u0435\u043d\u0442\u0440\u0430 \u044f\u0447\u0435\u0439\u043a\u0438. \u041e\u043d \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u043a \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435 \u0440\u0435\u0431\u0440\u0430 \u044f\u0447\u0435\u0439\u043a\u0438, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u044f\u0447\u0435\u0439\u043a\u0443. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u043a \u0446\u0435\u043d\u0442\u0440\u0443, \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u0441\u0440\u0430\u0437\u0443 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0440\u0435\u0431\u0440\u0443, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u044c. \u041f\u043e \u0441\u0443\u0442\u0438, \u043e\u0442\u0440\u044f\u0434 \u0431\u0443\u0434\u0435\u0442 \u0441\u0440\u0435\u0437\u0430\u0442\u044c \u043f\u0443\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0435\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u0441\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435. \u042d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u044f\u0447\u0435\u0435\u043a, \u043a\u0440\u043e\u043c\u0435 \u043a\u043e\u043d\u0446\u0435\u0432\u044b\u0445 \u0442\u043e\u0447\u0435\u043a \u043f\u0443\u0442\u0438.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/2bc\/8f0\/1b9\/2bc8f01b93b55b7acab8d9f56dd6f4be.png\"><\/div>\n<p>  <i>\u0422\u0440\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0440\u0435\u0431\u0440\u0430 \u043a \u0440\u0435\u0431\u0440\u0443.<\/i><\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u0443\u0435\u043c <code>OnDrawGizmos<\/code> \u043f\u043e\u0434 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043f\u0443\u0442\u0435\u0439, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u041e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u044e \u043c\u0435\u0436\u0434\u0443 \u0440\u0451\u0431\u0440\u0430\u043c\u0438 \u044f\u0447\u0435\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0443\u0441\u0440\u0435\u0434\u043d\u0435\u043d\u0438\u0435\u043c \u043f\u043e\u0437\u0438\u0446\u0438\u0439 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u044f\u0447\u0435\u0435\u043a. \u041d\u0430\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0440\u0435\u0431\u0440\u0443 \u043d\u0430 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044e, \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u043f\u043e\u0441\u043e\u0431 \u0438 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438, \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u0440\u0435\u0431\u0440\u0430 \u0432\u043e\u0437\u044c\u043c\u0451\u043c \u0435\u0451 \u043f\u043e\u0437\u0438\u0446\u0438\u044e.<\/p>\n<pre><code class=\"cs\">\tvoid OnDrawGizmos () { \t\tif (pathToTravel == null || pathToTravel.Count == 0) { \t\t\treturn; \t\t}  \t\tVector3 a, b = pathToTravel[0].Position;  \t\tfor (int i = 1; i &lt; pathToTravel.Count; i++) { \/\/\t\t\tVector3 a = pathToTravel[i - 1].Position; \/\/\t\t\tVector3 b = pathToTravel[i].Position; \t\t\ta = b; \t\t\tb = (pathToTravel[i - 1].Position + pathToTravel[i].Position) * 0.5f; \t\t\tfor (float t = 0f; t &lt; 1f; t += 0.1f) { \t\t\t\tGizmos.DrawSphere(Vector3.Lerp(a, b, t), 2f); \t\t\t} \t\t} \t}<\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u0446\u0435\u043d\u0442\u0440\u0430 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0442\u043e\u0447\u043a\u0438 \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u044f\u0447\u0435\u0439\u043a\u0438, \u0430 \u043d\u0435 \u0440\u0435\u0431\u0440\u043e. \u041c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u044d\u0442\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f \u0432 \u0446\u0438\u043a\u043b, \u043d\u043e \u044d\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u043e\u0434, \u0447\u0442\u043e \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434 \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0433\u043e.<\/p>\n<pre><code class=\"cs\">\tvoid OnDrawGizmos () { \t\t\u2026 \t\t \t\tfor (int i = 1; i &lt; pathToTravel.Count; i++) { \t\t\t\u2026 \t\t}  \t\ta = b; \t\tb = pathToTravel[pathToTravel.Count - 1].Position; \t\tfor (float t = 0f; t &lt; 1f; t += 0.1f) { \t\t\tGizmos.DrawSphere(Vector3.Lerp(a, b, t), 2f); \t\t} \t}<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/deb\/466\/4d4\/deb4664d4f8bcffcc3839dddfaa0d792.png\"><\/div>\n<p>  <i>\u041f\u0443\u0442\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0440\u0451\u0431\u0435\u0440.<\/i><\/p>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u043f\u0443\u0442\u0438 \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u043e\u0445\u043e\u0434\u044f\u0442 \u043d\u0430 \u0437\u0438\u0433\u0437\u0430\u0433\u0438, \u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0443\u0433\u043e\u043b \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430 \u0441\u043d\u0438\u0436\u0430\u0435\u0442\u0441\u044f \u0441 120\u00b0 \u0434\u043e 90\u00b0. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0442\u0435 \u0436\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u0435 <code>TravelPath<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438.<\/p>\n<pre><code class=\"cs\">\tIEnumerator TravelPath () { \t\tVector3 a, b = pathToTravel[0].Position;  \t\tfor (int i = 1; i &lt; pathToTravel.Count; i++) { \/\/\t\t\tVector3 a = pathToTravel[i - 1].Position; \/\/\t\t\tVector3 b = pathToTravel[i].Position; \t\t\ta = b; \t\t\tb = (pathToTravel[i - 1].Position + pathToTravel[i].Position) * 0.5f; \t\t\tfor (float t = 0f; t &lt; 1f; t += Time.deltaTime * travelSpeed) { \t\t\t\ttransform.localPosition = Vector3.Lerp(a, b, t); \t\t\t\tyield return null; \t\t\t} \t\t}  \t\ta = b; \t\tb = pathToTravel[pathToTravel.Count - 1].Position; \t\tfor (float t = 0f; t &lt; 1f; t += Time.deltaTime * travelSpeed) { \t\t\ttransform.localPosition = Vector3.Lerp(a, b, t); \t\t\tyield return null; \t\t} \t}<\/code><\/pre>\n<p>  <\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 60.4887%;\"><iframe src=\"https:\/\/gfycat.com\/ifr\/EuphoricReliableCarpenterant\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  <i>\u041f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0441 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0449\u0435\u0439\u0441\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e.<\/i><\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0441\u0440\u0435\u0437\u0430\u043d\u0438\u044f \u0443\u0433\u043b\u043e\u0432 \u0434\u043b\u0438\u043d\u0430 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u0443\u0442\u0438 \u0441\u0442\u0430\u043b\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0439 \u043e\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f. \u041d\u043e \u043c\u044b \u0437\u0430\u0434\u0430\u043b\u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0432 \u044f\u0447\u0435\u0439\u043a\u0430\u0445 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043e\u0442\u0440\u044f\u0434\u0430 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0445\u0430\u043e\u0442\u0438\u0447\u0435\u0441\u043a\u0438.<\/p>\n<h3>\u0421\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u043a\u0440\u0438\u0432\u044b\u043c<\/h3>\n<p>  \u041c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0438 \u0433\u0440\u0430\u043d\u0438\u0446 \u044f\u0447\u0435\u0435\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435\u043a\u0440\u0430\u0441\u0438\u0432\u043e. \u041b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u044d\u0442\u043e\u0433\u043e, \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0432 \u043e\u0442\u0440\u044f\u0434\u044b \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u043a\u0440\u0438\u0432\u044b\u043c, \u0430 \u043d\u0435 \u043f\u043e \u043f\u0440\u044f\u043c\u044b\u043c \u043b\u0438\u043d\u0438\u044f\u043c. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0440\u0438\u0432\u044b\u0435 \u0411\u0435\u0437\u044c\u0435. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u044b\u0435 \u043a\u0440\u0438\u0432\u044b\u0435 \u0411\u0435\u0437\u044c\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0440\u0435\u0434\u043d\u0438\u043c\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u044b\u043c\u0438 \u0442\u043e\u0447\u043a\u0430\u043c\u0438 \u0431\u0443\u0434\u0443\u0442 \u0446\u0435\u043d\u0442\u0440\u044b \u044f\u0447\u0435\u0435\u043a. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u043a\u0440\u0438\u0432\u044b\u0445 \u0431\u0443\u0434\u0443\u0442 \u0437\u0435\u0440\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043e\u0442\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430, \u0442\u043e \u0435\u0441\u0442\u044c \u0432\u0435\u0441\u044c \u043f\u0443\u0442\u044c \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u0432 \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u0443\u044e \u043f\u043b\u0430\u0432\u043d\u0443\u044e \u043a\u0440\u0438\u0432\u0443\u044e.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/a94\/c46\/0b8\/a94c460b8e7b3fd2ecc3b4ea4e3225a9.png\"><\/div>\n<p>  <i>\u041a\u0440\u0438\u0432\u044b\u0435 \u043e\u0442 \u0440\u0435\u0431\u0440\u0430 \u0434\u043e \u0440\u0435\u0431\u0440\u0430.<\/i><\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <code>Bezier<\/code> \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u043e\u0447\u043a\u0438 \u043d\u0430 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u043e\u0439 \u043a\u0440\u0438\u0432\u043e\u0439 \u0411\u0435\u0437\u044c\u0435. \u041a\u0430\u043a \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u043e \u0432 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435 <a href=\"https:\/\/catlikecoding.com\/unity\/tutorials\/curves-and-splines\/\">Curves and Splines<\/a>, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u043e\u0440\u043c\u0443\u043b\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/e20\/860\/4f3\/e208604f3b52353f4d54f1fd54c04b7b.svg\" alt=\"$(1 - t)^2 A + 2(1 - t) t B + t^2 C$\" data-tex=\"inline\"><\/math>, \u0433\u0434\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/493\/c1c\/008\/493c1c008018df9bed4910321f29ff00.svg\" alt=\"$A$\" data-tex=\"inline\"><\/math>, <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/20d\/8ca\/ec6\/20d8caec693d8d8eaf70885e408419f6.svg\" alt=\"$B$\" data-tex=\"inline\"><\/math> \u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/47e\/792\/77d\/47e79277dc17c254743475ff05980a53.svg\" alt=\"$C$\" data-tex=\"inline\"><\/math> \u2014 \u044d\u0442\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438, \u0430 t \u2014 \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0442\u043e\u0440.<\/p>\n<pre><code class=\"cs\">using UnityEngine;  public static class Bezier {  \tpublic static Vector3 GetPoint (Vector3 a, Vector3 b, Vector3 c, float t) { \t\tfloat r = 1f - t; \t\treturn r * r * a + 2f * r * t * b + t * t * c; \t} }<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0430\u0437\u0432\u0435 GetPoint \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0435 0-1?<\/b><\/p>\n<div class=\"spoiler_text\">\u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0442\u043e\u0440\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0435 0-1, \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0442\u044c. \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043f\u0440\u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u0438 \u043f\u043e \u043a\u0440\u0438\u0432\u044b\u043c \u0442\u0430\u043a\u043e\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430. \u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435, \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432\u0435\u0440\u0441\u0438\u044e <code>GetPointClamped<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>t<\/code>. \u0418\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u043c\u0435\u0442\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u0442\u044c <code>GetPointUnclamped<\/code>.<\/div>\n<\/div>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0440\u0438\u0432\u043e\u0439 \u043f\u0443\u0442\u044c \u0432 <code>OnDrawGizmos<\/code>, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043d\u0435 \u0434\u0432\u0435, \u0430 \u0442\u0440\u0438 \u0442\u043e\u0447\u043a\u0438. \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u2014 \u044d\u0442\u043e \u0446\u0435\u043d\u0442\u0440 \u044f\u0447\u0435\u0439\u043a\u0438, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438, \u0438\u043c\u0435\u044e\u0449\u0430\u044f \u0438\u043d\u0434\u0435\u043a\u0441 <code>i - 1<\/code>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0446\u0438\u043a\u043b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 1. \u041f\u043e\u043b\u0443\u0447\u0438\u0432 \u0432\u0441\u0435 \u0442\u043e\u0447\u043a\u0438, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c <code>Vector3.Lerp<\/code> \u043d\u0430 <code>Bezier.GetPoint<\/code>.<\/p>\n<p>  \u0412 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0430\u0445 \u0432\u043c\u0435\u0441\u0442\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0438 \u0441\u0440\u0435\u0434\u043d\u0435\u0439 \u0442\u043e\u0447\u043a\u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0446\u0435\u043d\u0442\u0440 \u044f\u0447\u0435\u0439\u043a\u0438.<\/p>\n<pre><code class=\"cs\">\tvoid OnDrawGizmos () { \t\tif (pathToTravel == null || pathToTravel.Count == 0) { \t\t\treturn; \t\t}  \t\tVector3 a, b, c = pathToTravel[0].Position;  \t\tfor (int i = 1; i &lt; pathToTravel.Count; i++) { \t\t\ta = c; \t\t\tb = pathToTravel[i - 1].Position; \t\t\tc = (b + pathToTravel[i].Position) * 0.5f; \t\t\tfor (float t = 0f; t &lt; 1f; t += Time.deltaTime * travelSpeed) { \t\t\t\tGizmos.DrawSphere(Bezier.GetPoint(a, b, c, t), 2f); \t\t\t} \t\t}  \t\ta = c; \t\tb = pathToTravel[pathToTravel.Count - 1].Position; \t\tc = b; \t\tfor (float t = 0f; t &lt; 1f; t += 0.1f) { \t\t\tGizmos.DrawSphere(Bezier.GetPoint(a, b, c, t), 2f); \t\t} \t}<\/code><\/pre>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/140\/79d\/cae\/14079dcae70b7b2522c137e0af848883.png\"><\/div>\n<p>  <i>\u041f\u0443\u0442\u0438, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u0440\u0438\u0432\u044b\u0445 \u0411\u0435\u0437\u044c\u0435.<\/i><\/p>\n<p>  \u041a\u0440\u0438\u0432\u043e\u0439 \u043f\u0443\u0442\u044c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043b\u0443\u0447\u0448\u0435. \u041f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0442\u0435 \u0436\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 <code>TravelPath<\/code> \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0430\u043d\u0438\u043c\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043e\u0442\u0440\u044f\u0434\u044b \u043f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435.<\/p>\n<pre><code class=\"cs\">\tIEnumerator TravelPath () { \t\tVector3 a, b, c = pathToTravel[0].Position;  \t\tfor (int i = 1; i &lt; pathToTravel.Count; i++) { \t\t\ta = c; \t\t\tb = pathToTravel[i - 1].Position; \t\t\tc = (b + pathToTravel[i].Position) * 0.5f; \t\t\tfor (float t = 0f; t &lt; 1f; t += Time.deltaTime * travelSpeed) { \t\t\t\ttransform.localPosition = Bezier.GetPoint(a, b, c, t); \t\t\t\tyield return null; \t\t\t} \t\t}  \t\ta = c; \t\tb = pathToTravel[pathToTravel.Count - 1].Position; \t\tc = b; \t\tfor (float t = 0f; t &lt; 1f; t += Time.deltaTime * travelSpeed) { \t\t\ttransform.localPosition = Bezier.GetPoint(a, b, c, t); \t\t\tyield return null; \t\t} \t}<\/code><\/pre>\n<p>  <\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 58.0484%;\"><iframe src=\"https:\/\/gfycat.com\/ifr\/SmoothKlutzyAmoeba\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  <i>\u041f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c\u0441\u044f \u043f\u043e \u043a\u0440\u0438\u0432\u044b\u043c.<\/i><\/p>\n<p>  \u0410\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u0442\u043e\u0436\u0435 \u0441\u0442\u0430\u043b\u0430 \u043f\u043b\u0430\u0432\u043d\u043e\u0439, \u0434\u0430\u0436\u0435 \u043a\u043e\u0433\u0434\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043e\u0442\u0440\u044f\u0434\u0430 \u043d\u0435\u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u0430. \u0422\u0430\u043a \u043a\u0430\u043a \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u0440\u0438\u0432\u043e\u0439 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442, \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u0430. \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u0438 \u0441\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043e\u0442\u0440\u044f\u0434 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0447\u0435\u0440\u0435\u0437 \u044f\u0447\u0435\u0439\u043a\u0443, \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u044f\u0441\u044c \u043f\u0440\u0438 \u0441\u043c\u0435\u043d\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u043e\u043d \u0438\u0434\u0451\u0442 \u043f\u0440\u044f\u043c\u043e, \u0442\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0439. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043e\u0442\u0440\u044f\u0434 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0438 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442 \u0441\u0432\u043e\u0439 \u043f\u0443\u0442\u044c \u0441 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e. \u042d\u0442\u043e \u0438\u043c\u0438\u0442\u0438\u0440\u0443\u0435\u0442 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0435\u0433\u043e \u0442\u0430\u043a\u0438\u043c.<\/p>\n<h3>\u041e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438<\/h3>\n<p>  \u0414\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043c\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u043b\u0438 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044e \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0438\u0437 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u043e\u0432 \u0441 0, \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044f, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0435\u043c 1. \u042d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 \u043d\u0430 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u0443\u044e \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443, \u043d\u043e \u043d\u0430\u0448\u0430 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0434\u0435\u043b\u044c\u0442\u044b \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041a\u043e\u0433\u0434\u0430 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044f \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0443 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f, \u043c\u044b \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u0435\u0432\u0437\u043e\u0439\u0434\u0451\u043c 1 \u043d\u0430 \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443, \u0437\u0430\u0432\u0438\u0441\u044f\u0449\u0443\u044e \u043e\u0442 \u0434\u0435\u043b\u044c\u0442\u044b \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u042d\u0442\u043e \u043d\u0435\u0437\u0430\u043c\u0435\u0442\u043d\u043e \u043f\u0440\u0438 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u043e\u0442\u0435 \u043a\u0430\u0434\u0440\u043e\u0432, \u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0440\u044b\u0432\u043a\u0430\u043c \u043f\u0440\u0438 \u043d\u0438\u0437\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u043e\u0442\u0435 \u043a\u0430\u0434\u0440\u043e\u0432.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u043e\u0442\u0435\u0440\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0441\u0442\u0430\u0432\u0448\u0435\u0435\u0441\u044f \u0432\u0440\u0435\u043c\u044f \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u044f <code>t<\/code> \u043d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 \u0432\u0441\u0435\u0433\u043e \u043f\u0443\u0442\u0438, \u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0435. \u0417\u0430\u0442\u0435\u043c \u0432 \u043a\u043e\u043d\u0446\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430 \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0437 \u043d\u0435\u0433\u043e 1.<\/p>\n<pre><code class=\"cs\">\tIEnumerator TravelPath () { \t\tVector3 a, b, c = pathToTravel[0].Position;  \t\tfloat t = 0f; \t\tfor (int i = 1; i &lt; pathToTravel.Count; i++) { \t\t\ta = c; \t\t\tb = pathToTravel[i - 1].Position; \t\t\tc = (b + pathToTravel[i].Position) * 0.5f; \t\t\tfor (; t &lt; 1f; t += Time.deltaTime * travelSpeed) { \t\t\t\ttransform.localPosition = Bezier.GetPoint(a, b, c, t); \t\t\t\tyield return null; \t\t\t} \t\t\tt -= 1f; \t\t}  \t\ta = c; \t\tb = pathToTravel[pathToTravel.Count - 1].Position; \t\tc = b; \t\tfor (; t &lt; 1f; t += Time.deltaTime * traveSpeed) { \t\t\ttransform.localPosition = Bezier.GetPoint(a, b, c, t); \t\t\tyield return null; \t\t} \t}<\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0443\u0436 \u043c\u044b \u044d\u0442\u0438\u043c \u0437\u0430\u043d\u044f\u043b\u0438\u0441\u044c, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0435\u0449\u0451 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0434\u0435\u043b\u044c\u0442\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u043b\u0430\u0441\u044c \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u0443\u0442\u0438. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043c\u044b \u043d\u0430\u0447\u043d\u0451\u043c \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0441\u0440\u0430\u0437\u0443 \u0436\u0435, \u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0430\u0438\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u043a\u0430\u0434\u0440.<\/p>\n<pre><code class=\"cs\">\t\tfloat t = Time.deltaTime * travelSpeed;<\/code><\/pre>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u044b \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u043c \u043d\u0435 \u0442\u043e\u0447\u043d\u043e \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043a\u043e\u0433\u0434\u0430 \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u044c\u0441\u044f \u043f\u0443\u0442\u044c, \u0430 \u0437\u0430 \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u0434\u043e \u044d\u0442\u043e\u0433\u043e. \u0417\u0434\u0435\u0441\u044c \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u043a\u0430\u0434\u0440\u043e\u0432. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u0440\u044f\u0434 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u043b \u043f\u0443\u0442\u044c \u0440\u043e\u0432\u043d\u043e \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0435.<\/p>\n<pre><code class=\"cs\">\tIEnumerator TravelPath () { \t\t\u2026  \t\ttransform.localPosition = location.Position; \t}<\/code><\/pre>\n<p>  <a href=\"https:\/\/catlikecoding.com\/unity\/tutorials\/hex-map\/part-19\/flowing-movement\/flowing-movement.unitypackage\" rel=\"nofollow\">unitypackage<\/a><\/p>\n<h2>\u0410\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/h2>\n<p>  \u041e\u0442\u0440\u044f\u0434\u044b \u043d\u0430\u0447\u0430\u043b\u0438 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u043f\u043b\u0430\u0432\u043d\u043e\u0439 \u043a\u0440\u0438\u0432\u043e\u0439, \u043d\u043e \u043e\u043d\u0438 \u043d\u0435 \u043c\u0435\u043d\u044f\u044e\u0442 \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043e\u043d\u0438 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0442. \u0427\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u043e \u043a\u0430\u043a \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0445 \u043f\u043e\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c.<\/p>\n<h3>\u0421\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u043f\u0435\u0440\u0451\u0434<\/h3>\n<p>  \u041a\u0430\u043a \u0438 \u0432 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435 <a href=\"https:\/\/catlikecoding.com\/unity\/tutorials\/curves-and-splines\/\">Curves and Splines<\/a>, \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043e\u0442\u0440\u044f\u0434\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u0443\u044e \u043a\u0440\u0438\u0432\u043e\u0439. \u0424\u043e\u0440\u043c\u0443\u043b\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u0439 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u043e\u0439 \u043a\u0440\u0438\u0432\u043e\u0439 \u0411\u0435\u0437\u044c\u0435: <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/251\/4db\/6da\/2514db6da672030d27678c3106f5a50e.svg\" alt=\"$2 ((1 - t) (B - A) + t (C - B))$\" data-tex=\"inline\"><\/math>. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432 <code>Bezier<\/code> \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0435\u0451 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"cs\">\tpublic static Vector3 GetDerivative ( \t\tVector3 a, Vector3 b, Vector3 c, float t \t) { \t\treturn 2f * ((1f - t) * (b - a) + t * (c - b)); \t}<\/code><\/pre>\n<p>  \u0412\u0435\u043a\u0442\u043e\u0440 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u0439 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u043f\u0440\u044f\u043c\u043e\u0439 \u0441 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>Quaternion.LookRotation<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043f\u043e\u0432\u043e\u0440\u043e\u0442 \u043e\u0442\u0440\u044f\u0434\u0430. \u0411\u0443\u0434\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u044d\u0442\u043e \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0448\u0430\u0433\u0443 \u0432 <code>HexUnit.TravelPath<\/code>.<\/p>\n<pre><code class=\"cs\">\t\t\t\ttransform.localPosition = Bezier.GetPoint(a, b, c, t); \t\t\t\tVector3 d = Bezier.GetDerivative(a, b, c, t); \t\t\t\ttransform.localRotation = Quaternion.LookRotation(d); \t\t\t\tyield return null; \t\t \t\t\u2026 \t\t \t\t\ttransform.localPosition = Bezier.GetPoint(a, b, c, t); \t\t\tVector3 d = Bezier.GetDerivative(a, b, c, t); \t\t\ttransform.localRotation = Quaternion.LookRotation(d); \t\t\tyield return null;<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0430\u0437\u0432\u0435 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u0443\u0442\u0438 \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430?<\/b><\/p>\n<div class=\"spoiler_text\">\u041f\u0443\u0442\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043a\u0440\u0438\u0432\u043e\u0439, \u0438\u0434\u0443\u0449\u0435\u0439 \u043e\u0442 \u0446\u0435\u043d\u0442\u0440\u0430 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438 \u0434\u043e \u0435\u0451 \u0440\u0435\u0431\u0440\u0430. \u041c\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0442\u043e\u0447\u043a\u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/493\/c1c\/008\/493c1c008018df9bed4910321f29ff00.svg\" alt=\"$A$\" data-tex=\"inline\"><\/math> \u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/20d\/8ca\/ec6\/20d8caec693d8d8eaf70885e408419f6.svg\" alt=\"$B$\" data-tex=\"inline\"><\/math> \u043a\u0440\u0438\u0432\u043e\u0439 \u0440\u0430\u0432\u043d\u044b\u043c\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043a\u0440\u0430\u0441\u0438\u0432\u043e\u0435 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043a\u043e\u0433\u0434\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/267\/68f\/254\/26768f2546a9c33d522388c196dc0a57.svg\" alt=\"$t = 0$\" data-tex=\"inline\"><\/math>, \u0442\u043e \u0432\u0435\u043a\u0442\u043e\u0440 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u0439 \u0440\u0430\u0432\u0435\u043d \u043d\u0443\u043b\u044e, \u0430 \u0435\u0433\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 <code>Quaternion.LookRotation<\/code>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430, \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0435\u0441\u043b\u0438 \u043c\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/267\/68f\/254\/26768f2546a9c33d522388c196dc0a57.svg\" alt=\"$t = 0$\" data-tex=\"inline\"><\/math> \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430. \u041d\u043e \u043c\u044b \u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u043c. \u041c\u044b \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441 \u0434\u0435\u043b\u044c\u0442\u044b \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/0a6\/464\/a18\/0a6464a18a39f7704cf2bf52d204439a.svg\" alt=\"$t &gt; 0$\" data-tex=\"inline\"><\/math> \u0438 \u0441\u043f\u043e\u0441\u043e\u0431 \u0432\u0441\u0435\u0433\u0434\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<br \/>  \u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u0438 \u043a \u043a\u043e\u043d\u0446\u0443 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0435\u0439\u0441\u044f \u043a\u0440\u0438\u0432\u043e\u0439, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/33a\/163\/c89\/33a163c89ec90be93eb06df3e5c42267.svg\" alt=\"$t &lt; 1$\" data-tex=\"inline\"><\/math>.<\/div>\n<\/div>\n<p>  \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u043e\u0442\u0440\u044f\u0434\u0430, \u043d\u0435\u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0435\u0433\u043e \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043f\u0443\u0442\u0438 \u043d\u0435 \u0432\u0430\u0436\u043d\u0430. \u043e\u0434\u043d\u0430\u043a\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0435\u0433\u043e \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0443. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0440\u0430\u0432\u043d\u044f\u0435\u043c \u0435\u0433\u043e \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u043a \u0435\u0433\u043e \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0443 \u043f\u043e Y.<\/p>\n<pre><code class=\"cs\">\t\ttransform.localPosition = location.Position; \t\torientation = transform.localRotation.eulerAngles.y;<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0442\u0440\u044f\u0434\u044b \u0441\u043c\u043e\u0442\u0440\u044f\u0442 \u0442\u043e\u0447\u043d\u043e \u0432 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f, \u0438 \u043f\u043e \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u0438, \u0438 \u043f\u043e \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u0438. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u043a\u043b\u043e\u043d\u044f\u0442\u044c\u0441\u044f \u0432\u043f\u0435\u0440\u0451\u0434 \u0438 \u043d\u0430\u0437\u0430\u0434, \u0441\u043f\u0443\u0441\u043a\u0430\u044f\u0441\u044c \u0441\u043e \u0441\u043a\u043b\u043e\u043d\u043e\u0432 \u0438 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u044f\u0441\u044c \u043d\u0430 \u043d\u0438\u0445. \u0427\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u0442\u043e\u044f\u043b\u0438 \u043f\u0440\u044f\u043c\u043e, \u043f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u043d\u0443\u043b\u0438\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 Y \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0434 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430 \u043e\u0442\u0440\u044f\u0434\u0430.<\/p>\n<pre><code class=\"cs\">\t\t\t\tVector3 d = Bezier.GetDerivative(a, b, c, t); \t\t\t\td.y = 0f; \t\t\t\ttransform.localRotation = Quaternion.LookRotation(d); \t\t \t\t\u2026 \t\t \t\t\tVector3 d = Bezier.GetDerivative(a, b, c, t); \t\t\td.y = 0f; \t\t\ttransform.localRotation = Quaternion.LookRotation(d);<\/code><\/pre>\n<p>  <\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 58.9102%;\"><iframe src=\"https:\/\/gfycat.com\/ifr\/RemoteReadyGordonsetter\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  <i>\u0421\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u043f\u0435\u0440\u0451\u0434 \u043f\u0440\u0438 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0438.<\/i><\/p>\n<h3>\u0421\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0442\u043e\u0447\u043a\u0443<\/h3>\n<p>  \u041d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 \u0432\u0441\u0435\u0433\u043e \u043f\u0443\u0442\u0438 \u043e\u0442\u0440\u044f\u0434\u044b \u0441\u043c\u043e\u0442\u0440\u044f\u0442 \u0432\u043f\u0435\u0440\u0451\u0434, \u043d\u043e \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u0447\u0430\u043b\u043e\u043c \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d\u0438 \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e \u043c\u0435\u043d\u044f\u044e\u0442 \u0441\u0432\u043e\u044e \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u044e. \u0411\u0443\u0434\u0435\u0442 \u043b\u0443\u0447\u0448\u0435, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043f\u0443\u0442\u0438 \u0435\u0449\u0451 \u0434\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u0412\u0437\u0433\u043b\u044f\u0434 \u0432 \u043d\u0443\u0436\u043d\u043e\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0438 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u0435\u0442\u043e\u0434 <code>LookAt<\/code>, \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u043e\u0442\u0440\u044f\u0434 \u043c\u0435\u043d\u044f\u0442\u044c \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u044e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443. \u0422\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0439 \u043f\u043e\u0432\u043e\u0440\u043e\u0442 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 <code>Transform.LookAt<\/code>, \u0441\u0434\u0435\u043b\u0430\u0432 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0442\u043e\u0447\u043a\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u043b\u0430\u0441\u044c \u0432 \u0442\u043e\u0439 \u0436\u0435 \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438, \u0447\u0442\u043e \u0438 \u043e\u0442\u0440\u044f\u0434. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u043e\u0442\u0440\u044f\u0434\u0430.<\/p>\n<pre><code class=\"cs\">\tvoid LookAt (Vector3 point) { \t\tpoint.y = transform.localPosition.y; \t\ttransform.LookAt(point); \t\torientation = transform.localRotation.eulerAngles.y; \t}<\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043e\u0442\u0440\u044f\u0434 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043f\u043e\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043b\u0441\u044f, \u043c\u044b \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043c \u043c\u0435\u0442\u043e\u0434 \u0432 \u0435\u0449\u0451 \u043e\u0434\u043d\u0443 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0435\u0433\u043e \u0441 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0439 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e. \u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430 \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c\u043e\u0439, \u043d\u043e \u043c\u044b \u0441\u043d\u043e\u0432\u0430 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043e\u0439. \u041f\u043e\u0432\u043e\u0440\u043e\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u043c, \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e 180\u00b0 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443.<\/p>\n<pre><code class=\"cs\">\tconst float rotationSpeed = 180f; \t \t\u2026  \tIEnumerator LookAt (Vector3 point) { \t\t\u2026 \t}<\/code><\/pre>\n<p>  \u0412\u043e\u0437\u0438\u0442\u044c\u0441\u044f \u0441 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435\u043c \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d\u043e \u043d\u0435\u0437\u0430\u043c\u0435\u0442\u043d\u043e. \u041d\u0430\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u044e \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u044f\u043c\u0438. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e, \u043a\u0430\u043a \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0434\u0432\u0443\u043c\u044f \u0447\u0438\u0441\u043b\u0430\u043c\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0443\u0433\u043b\u044b \u043a\u0440\u0443\u0433\u043e\u0432\u044b\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u0438\u0437 350\u00b0 \u0432 10\u00b0 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0443 \u043d\u0430 20\u00b0 \u043f\u043e \u0447\u0430\u0441\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0435\u043b\u043a\u0435, \u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u044f \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u043e\u0432\u043e\u0440\u043e\u0442 \u043d\u0430 340\u00b0 \u043f\u0440\u043e\u0442\u0438\u0432 \u0447\u0430\u0441\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0435\u043b\u043a\u0438.<\/p>\n<p>  \u041f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0432\u043e\u0440\u043e\u0442, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u044e \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d\u0430\u043c\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0444\u0435\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u0438. \u042d\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u043a\u0440\u0430\u0442\u043a\u043e\u043c\u0443 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0443. \u0427\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e, \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d\u044b \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u043a\u043e\u043d\u0446\u0430, \u0430 \u043f\u043e\u0442\u043e\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>Quaternion.Slerp<\/code>.<\/p>\n<pre><code class=\"cs\">\tIEnumerator LookAt (Vector3 point) { \t\tpoint.y = transform.localPosition.y; \t\tQuaternion fromRotation = transform.localRotation; \t\tQuaternion toRotation = \t\t\tQuaternion.LookRotation(point - transform.localPosition); \t\t \t\tfor (float t = Time.deltaTime; t &lt; 1f; t += Time.deltaTime) { \t\t\ttransform.localRotation = \t\t\t\tQuaternion.Slerp(fromRotation, toRotation, t); \t\t\tyield return null; \t\t}  \t\ttransform.LookAt(point); \t\torientation = transform.localRotation.eulerAngles.y; \t}<\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043d\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u044f \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0434\u0451\u0442 \u043e\u0442 0 \u0434\u043e 1, \u0432\u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0443\u0433\u043b\u0430 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430. \u0427\u0442\u043e\u0431\u044b \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u0443\u044e \u0443\u0433\u043b\u043e\u0432\u0443\u044e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u044e \u043f\u0440\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 \u0443\u0433\u043b\u0430 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430.<\/p>\n<pre><code class=\"cs\">\t\tQuaternion fromRotation = transform.localRotation; \t\tQuaternion toRotation = \t\t\tQuaternion.LookRotation(point - transform.localPosition); \t\tfloat angle = Quaternion.Angle(fromRotation, toRotation); \t\tfloat speed = rotationSpeed \/ angle; \t\t \t\tfor ( \t\t\tfloat t = Time.deltaTime * speed; \t\t\tt &lt; 1f; \t\t\tt += Time.deltaTime * speed \t\t) { \t\t\ttransform.localRotation = \t\t\t\tQuaternion.Slerp(fromRotation, toRotation, t); \t\t\tyield return null; \t\t}<\/code><\/pre>\n<p>  \u0417\u043d\u0430\u044f \u0443\u0433\u043e\u043b, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u043e\u0432\u043e\u0440\u043e\u0442, \u0435\u0441\u043b\u0438 \u043e\u043d \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0443\u043b\u0435\u0432\u044b\u043c.<\/p>\n<pre><code class=\"cs\">\t\tfloat angle = Quaternion.Angle(fromRotation, toRotation);  \t\tif (angle &gt; 0f) { \t\t\tfloat speed = rotationSpeed \/ angle; \t\t\tfor ( \t\t\t\t\u2026 \t\t\t) { \t\t\t\t\u2026 \t\t\t} \t\t}<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0432\u043e\u0440\u043e\u0442 \u043e\u0442\u0440\u044f\u0434\u0430 \u0432 <code>TravelPath<\/code>, \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044f \u043f\u0435\u0440\u0435\u0434 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435\u043c yield <code>LookAt<\/code> \u0441 \u043f\u043e\u0437\u0438\u0446\u0438\u0435\u0439 \u0432\u0442\u043e\u0440\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438. Unity \u0431\u0443\u0434\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u0443 <code>LookAt<\/code>, \u0430 <code>TravelPath<\/code> \u0431\u0443\u0434\u0435\u0442 \u0436\u0434\u0430\u0442\u044c \u0435\u0451 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"cs\">\tIEnumerator TravelPath () { \t\tVector3 a, b, c = pathToTravel[0].Position; \t\tyield return LookAt(pathToTravel[1].Position);  \t\tfloat t = Time.deltaTime * travelSpeed; \t\t\u2026 \t}<\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u043a\u043e\u0434\u0430, \u0442\u043e \u043e\u0442\u0440\u044f\u0434 \u0442\u0435\u043b\u0435\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u0443\u044e \u044f\u0447\u0435\u0439\u043a\u0443, \u043f\u043e\u0432\u0435\u0440\u043d\u0451\u0442\u0441\u044f \u0442\u0430\u043c, \u0430 \u0437\u0430\u0442\u0435\u043c \u0442\u0435\u043b\u0435\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043a \u043d\u0430\u0447\u0430\u043b\u0443 \u043f\u0443\u0442\u0438 \u0438 \u043d\u0430\u0447\u043d\u0451\u0442 \u043e\u0442\u0442\u0443\u0434\u0430 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435. \u0422\u0430\u043a \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 <code>Location<\/code> \u0434\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b <code>TravelPath<\/code>. \u0427\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0442\u0435\u043b\u0435\u043f\u043e\u0440\u0442\u0430\u0446\u0438\u0438, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 <code>TravelPath<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u043e\u0442\u0440\u044f\u0434\u0430 \u0432 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u044f\u0447\u0435\u0439\u043a\u0443.<\/p>\n<pre><code class=\"cs\">\t\tVector3 a, b, c = pathToTravel[0].Position; \t\ttransform.localPosition = c; \t\tyield return LookAt(pathToTravel[1].Position);<\/code><\/pre>\n<p>  <\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 72.1657%;\"><iframe src=\"https:\/\/gfycat.com\/ifr\/AbandonedEllipticalIberianemeraldlizard\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  <i>\u041f\u043e\u0432\u043e\u0440\u043e\u0442 \u043f\u0435\u0440\u0435\u0434 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435\u043c.<\/i><\/p>\n<h3>\u041f\u043e\u0434\u0447\u0438\u0441\u0442\u043a\u0430<\/h3>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0438\u0432 \u043d\u0443\u0436\u043d\u043e\u0435 \u043d\u0430\u043c \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u043c\u0435\u0442\u043e\u0434\u0430 <code>OnDrawGizmos<\/code>. \u0423\u0434\u0430\u043b\u0438\u0442\u0435 \u0435\u0433\u043e \u0438\u043b\u0438 \u0437\u0430\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0432\u0438\u0434\u0435\u0442\u044c \u043f\u0443\u0442\u0438.<\/p>\n<pre><code class=\"cs\">\/\/\tvoid OnDrawGizmos () { \/\/\t\t\u2026 \/\/\t}<\/code><\/pre>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c, \u043f\u043e \u043a\u0430\u043a\u043e\u043c\u0443 \u043f\u0443\u0442\u0438 \u043c\u044b \u0434\u0432\u0438\u0433\u0430\u043b\u0438\u0441\u044c, \u0442\u043e \u0432 \u043a\u043e\u043d\u0446\u0435 <code>TravelPath<\/code> \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u044f\u0447\u0435\u0435\u043a.<\/p>\n<pre><code class=\"cs\">\tIEnumerator TravelPath () { \t\t\u2026 \t\tListPool&lt;HexCell&gt;.Add(pathToTravel); \t\tpathToTravel = null; \t}<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0410 \u043a\u0430\u043a \u043d\u0430\u0441\u0447\u0451\u0442 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0445 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0439 \u043e\u0442\u0440\u044f\u0434\u043e\u0432?<\/b><\/p>\n<div class=\"spoiler_text\">\u0422\u0430\u043a \u043a\u0430\u043a \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0442\u0440\u044f\u0434\u0430 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u0443\u0431, \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u043c \u043d\u0435\u0447\u0435\u0433\u043e. \u041d\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 3D-\u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0441\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u0438 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0439 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438\u043c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438. \u0410\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u043d\u044b \u0431\u044b\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438. \u0414\u043b\u044f \u043c\u0435\u043b\u043a\u0438\u0445 \u043e\u0442\u0440\u044f\u0434\u043e\u0432 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0438\u0433\u0440 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0445 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u0438 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u0441\u043c\u0435\u0448\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Mecanim, \u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 <code>TravelPath<\/code>.<\/div>\n<\/div>\n<p>  <a href=\"https:\/\/catlikecoding.com\/unity\/tutorials\/hex-map\/part-19\/animating-orientation\/animating-orientation.unitypackage\" rel=\"nofollow\">unitypackage<\/a><\/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\/post\/426481\/\"> https:\/\/habr.com\/post\/426481\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\"><a href=\"https:\/\/habr.com\/post\/424257\/\">\u0427\u0430\u0441\u0442\u0438 1-3: \u0441\u0435\u0442\u043a\u0430, \u0446\u0432\u0435\u0442\u0430 \u0438 \u0432\u044b\u0441\u043e\u0442\u044b \u044f\u0447\u0435\u0435\u043a.<\/a><\/p>\n<p>  <a href=\"https:\/\/habr.com\/post\/424491\/\">\u0427\u0430\u0441\u0442\u0438 4-7: \u043d\u0435\u0440\u043e\u0432\u043d\u043e\u0441\u0442\u0438, \u0440\u0435\u043a\u0438 \u0438 \u0434\u043e\u0440\u043e\u0433\u0438.<\/a><\/p>\n<p>  <a href=\"https:\/\/habr.com\/post\/425463\/\">\u0427\u0430\u0441\u0442\u0438 8-11: \u0432\u043e\u0434\u0430, \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0440\u0435\u043b\u044c\u0435\u0444\u0430 \u0438 \u043a\u0440\u0435\u043f\u043e\u0441\u0442\u043d\u044b\u0435 \u0441\u0442\u0435\u043d\u044b<\/a><\/p>\n<p>  <a href=\"https:\/\/habr.com\/post\/425919\/\">\u0427\u0430\u0441\u0442\u0438 12-15: \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430, \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b, \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f<\/a><\/p>\n<h1>\u0427\u0430\u0441\u0442\u044c 16: \u043f\u043e\u0438\u0441\u043a \u043f\u0443\u0442\u0438<\/h1>\n<p>  <\/p>\n<ul>\n<li>\u041f\u043e\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u0435\u043c \u044f\u0447\u0435\u0439\u043a\u0438.<\/li>\n<li>\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0446\u0435\u043b\u0435\u0432\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u043f\u043e\u0438\u0441\u043a\u0430.<\/li>\n<li>\u041d\u0430\u0445\u043e\u0434\u0438\u043c \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0438\u0439 \u043f\u0443\u0442\u044c.<\/li>\n<li>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u043c.<\/li>\n<\/ul>\n<p>  \u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0432 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u044f\u0447\u0435\u0439\u043a\u0430\u043c\u0438, \u043c\u044b \u043f\u0435\u0440\u0435\u0448\u043b\u0438 \u043a \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044e \u043f\u0443\u0442\u0435\u0439 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438.<\/p>\n<p>  \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u044b \u043f\u043e \u043a\u0430\u0440\u0442\u0430\u043c \u0438\u0437 \u0448\u0435\u0441\u0442\u0438\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 Unity 5.6.0. \u041d\u0443\u0436\u043d\u043e \u0443\u0447\u0435\u0441\u0442\u044c, \u0447\u0442\u043e \u0432 5.6 \u0435\u0441\u0442\u044c \u0431\u0430\u0433, \u0440\u0430\u0437\u0440\u0443\u0448\u0430\u044e\u0449\u0438\u0439 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0442\u0435\u043a\u0441\u0442\u0443\u0440 \u0432 \u0441\u0431\u043e\u0440\u043a\u0430\u0445 \u0434\u043b\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c. \u041e\u0431\u043e\u0439\u0442\u0438 \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e, \u0432\u043a\u043b\u044e\u0447\u0438\u0432 \u0432 \u0438\u043d\u0441\u043f\u0435\u043a\u0442\u043e\u0440\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440 <em>Is Readable<\/em>.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/1d9\/165\/c4e\/1d9165c4e1862b050015df3c9dcc48cd.jpg\"><\/div>\n<p>  <i>\u041f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u043c \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u0435.<\/i>  <\/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-291275","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/291275","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=291275"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/291275\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=291275"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=291275"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=291275"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}