{"id":182382,"date":"2013-06-07T16:56:03","date_gmt":"2013-06-07T12:56:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=182382"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=182382","title":{"rendered":"<span class=\"post_title\">Boid&#8217;\u044b, \u043f\u0442\u0438\u0447\u043a\u0438 \u0438 Unity3D<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t<img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/f8c\/268\/1a1\/f8c2681a18cf9cd6e5265f4fa2aca240.gif\"\/><\/p>\n<p>  \u0417\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u043b\u0438 \u0432\u044b \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u043e \u0442\u043e, \u043f\u043e\u0447\u0435\u043c\u0443 \u043f\u0442\u0438\u0446\u044b \u043b\u0435\u0442\u0430\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0441\u0442\u0430\u044f\u043c\u0438 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0438 \u043d\u0435 \u043a\u043e\u043b\u043b\u0430\u043f\u0441\u0438\u0440\u0443\u044e\u0442 \u0432 \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u0439 \u0433\u0430\u043b\u0434\u044f\u0449\u0438\u0439 \u043f\u0435\u0440\u044c\u0435\u0432\u043e\u0439 \u043a\u043e\u043c? \u0425\u043c, \u0435\u0441\u043b\u0438 \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c, \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043a\u0440\u0443\u0442\u043e. \u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043e\u0434\u043d\u0430\u0436\u0434\u044b \u0432 1986 \u043d\u0430\u0448\u0451\u043b\u0441\u044f \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u043f\u043e \u0438\u043c\u0435\u043d\u0438 <a href=\"http:\/\/www.red3d.com\/cwr\/index.html\">\u041a\u0440\u0435\u0439\u0433 \u0420\u0435\u0439\u043d\u043e\u043b\u044c\u0434\u0441<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0448\u0438\u043b \u0441\u043e\u0437\u0434\u0430\u0442\u044c <a href=\"http:\/\/www.red3d.com\/cwr\/boids\/\">\u043f\u0440\u043e\u0441\u0442\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043f\u0442\u0438\u0446 \u0432 \u0441\u0442\u0430\u044f\u0445 \u0438 \u043d\u0430\u0437\u0432\u0430\u043b \u0435\u0451 Boids<\/a>. \u0412 \u043c\u043e\u0434\u0435\u043b\u0438 \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0431\u043e\u0438\u0434\u0430 \u0435\u0441\u0442\u044c \u0442\u0440\u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043f\u0440\u0430\u0432\u0438\u043b\u0430: Separation, Alignment \u0438 Cohesion. \u041f\u0435\u0440\u0432\u043e\u0435 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0438\u0437\u0431\u0435\u0433\u0430\u043d\u0438\u0438 \u0441\u0442\u043e\u043b\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u0441 \u0441\u043e\u0441\u0435\u0434\u044f\u043c\u0438, \u0432\u0442\u043e\u0440\u043e\u0435 \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043b\u0435\u0442\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432 \u0442\u0443 \u0436\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0447\u0442\u043e \u0438 \u0441\u043e\u0441\u0435\u0434\u0438, \u0430 \u0442\u0440\u0435\u0442\u044c\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0435 \u043b\u0435\u0442\u0430\u0442\u044c \u0432 \u043e\u0434\u0438\u043d\u043e\u0447\u043a\u0443 \u0438 \u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f \u0433\u0440\u0443\u043f\u043f\u044b. \u042d\u0442\u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0441\u0442\u0430\u0438 \u043f\u0442\u0438\u0446, \u0440\u044b\u0431 \u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u0436\u0438\u0432\u043d\u043e\u0441\u0442\u0438, \u0447\u0435\u043c \u0438 \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u043a\u0438\u043d\u043e \u0438 \u0438\u0433\u0440\u043e\u0432\u043e\u0439 \u0438\u043d\u0434\u0443\u0441\u0442\u0440\u0438\u0438.<\/p>\n<p>  \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435. \u0414\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e <a href=\"http:\/\/unity3d.com\/\">Unity<\/a> \u0438 C#, \u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0432\u0435\u0449\u0435\u0439 \u0432\u0435\u0440\u043d\u044b \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u0434\u0432\u0438\u0436\u043a\u043e\u0432 \u0438 \u044f\u0437\u044b\u043a\u043e\u0432. \u0412 \u044d\u0442\u043e\u043c \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435 \u044f \u043d\u0435 \u0440\u0430\u0437\u0436\u0451\u0432\u044b\u0432\u0430\u044e \u043e\u0441\u043d\u043e\u0432\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Unity, \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435 \u044d\u0444\u0444\u0435\u043a\u0442 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 Ctrl+Shift+N \u043d\u0430 \u0441\u0446\u0435\u043d\u0435, \u0443\u043c\u0435\u0435\u0442\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0438\u043d\u0441\u043f\u0435\u043a\u0442\u043e\u0440\u043e\u043c, \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0434\u0432\u0438\u0433\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b. \u0415\u0441\u043b\u0438 \u043d\u0435\u0442, \u0442\u043e \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u043d\u0430\u0447\u0430\u0442\u044c <a href=\"http:\/\/habrahabr.ru\/post\/167509\/\">\u0441 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438<\/a>. \u0418\u043b\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>\u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u043f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u0438\u044f<\/h4>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/61c\/d1c\/856\/61cd1c856d04f7add4d49b99f570cf04.jpg\"\/><\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0432 Unity \u0438 \u0441\u0440\u0430\u0437\u0443 \u0441\u043e\u043e\u0440\u0443\u0434\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0430\u043f\u043e\u0447\u0435\u043a \u043d\u0430 \u0431\u0443\u0434\u0443\u0449\u0435\u0435: Materials, Prefabs, Scenes, Scripts.<br \/>  \u0417\u0430\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u043c \u043d\u0430 \u0441\u0446\u0435\u043d\u0443 Directional Light \u0438 \u043e\u0434\u043d\u0443 \u0441\u0444\u0435\u0440\u0443 \u043f\u043e \u0438\u043c\u0435\u043d\u0438 Boid. \u0421\u0444\u0435\u0440\u0443 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0432 \u043f\u0440\u0435\u0444\u0430\u0431. \u0417\u0430\u043e\u0434\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0441\u0446\u0435\u043d\u0443, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0442\u043e\u043c \u043e\u0431 \u044d\u0442\u043e\u043c \u043d\u0435 \u0434\u0443\u043c\u0430\u0442\u044c. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u0441\u043a\u0440\u0438\u043f\u0442\u0438\u043d\u0433\u0443.<\/p>\n<p>  \u0414\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430\u043c \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0442\u0440\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430: Separation, Alignment \u0438 Cohesion. \u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e, \u043e\u043d \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439. \u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u044d\u0442\u043e \u0432\u0435\u043a\u0442\u043e\u0440, \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0446\u0435\u043d\u0442\u0440\u0430 \u043e\u043a\u0440\u0435\u0441\u0442\u043d\u044b\u0445 \u0431\u043e\u0438\u0434\u043e\u0432. \u0414\u043b\u044f \u0435\u0433\u043e \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u043e \u0441\u043b\u043e\u0436\u0438\u0442\u044c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0431\u043e\u0438\u0434\u043e\u0432 \u0438 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0443\u043c\u043c\u0443 \u043d\u0430 \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e. \u041a\u0430\u043a \u0431\u043e\u0438\u0434 \u0443\u0437\u043d\u0430\u0435\u0442, \u0447\u0442\u043e \u0443 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u0441\u043e\u0441\u0435\u0434\u0438? \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f <a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Physics.OverlapSphere.html\">Physics.OverlapSphere<\/a>. \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0438\u0442 \u043d\u0430\u043c \u0432\u0441\u0435 \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440\u044b \u0432 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c cohesionRadius, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0438\u0434\u0430, \u0435\u0441\u043b\u0438 \u043e\u043d \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u0441\u0444\u0435\u0440\u0443.  <\/p>\n<pre><code class=\"cs\">boids = Physics.OverlapSphere(transform.position, cohesionRadius); <\/code><\/pre>\n<p>  \u041c\u044b \u043e\u0431\u043d\u0443\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u043f\u043b\u044e\u0441\u0443\u0435\u043c, \u0434\u0435\u043b\u0438\u043c, \u0430 \u043f\u043e\u0442\u043e\u043c \u0440\u0438\u0441\u0443\u0435\u043c \u043a \u0446\u0435\u043d\u0442\u0440\u0443 \u0440\u0430\u0437\u0443\u043a\u0440\u0430\u0448\u0435\u043d\u043d\u0443\u044e \u043b\u0438\u043d\u0438\u044e \u043e\u0442 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430 \u0431\u043e\u0438\u0434\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0443\u043f\u0435\u0440\u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 <a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Debug.DrawLine.html\">Debug.DrawLine<\/a> \u0438 <a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Color-magenta.html\">Color.magenta<\/a>. <a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Debug.DrawLine.html\">Debug.DrawLine<\/a> \u043d\u0430 \u0432\u0445\u043e\u0434 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u043a\u043e\u043d\u0446\u0430 \u043b\u0438\u043d\u0438\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0446\u0432\u0435\u0442\u0430 \u043b\u0438\u043d\u0438\u0438. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0434\u0435\u0431\u0430\u0436\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432\u0438\u0434\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0432 \u0431\u0438\u043b\u0434 \u043e\u043d\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442.  <\/p>\n<pre><code class=\"cs\">Debug.DrawLine(transform.position, cohesion, Color.magenta); <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Boid.cs \u0446\u0435\u043d\u0442\u0440<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">using UnityEngine;  public class Boid : MonoBehaviour {     private Vector3 cohesion;     private float cohesionRadius = 10;     private Collider[] boids;      void Update()     {         cohesion = Vector3.zero;         boids = Physics.OverlapSphere(transform.position, cohesionRadius);         foreach (var boid in boids)         {             cohesion += boid.transform.position;         }         cohesion = cohesion \/ boids.Length;         Debug.DrawLine(transform.position, cohesion, Color.magenta);     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u041a\u0438\u0434\u0430\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442 \u043d\u0430 \u043f\u0440\u0435\u0444\u0430\u0431, \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0431\u043e\u0439\u0434 \u043f\u0430\u0440\u0443 \u0440\u0430\u0437 \u0438 \u0436\u043c\u0451\u043c Play. \u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0435 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 Gizmos \u0438\u043d\u0430\u0447\u0435 \u043d\u0435 \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043b\u0438\u043d\u0438\u0438.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/a18\/493\/2e7\/a184932e7ed1cff2caa0d930daf4cee3.jpg\"\/><\/p>\n<h4>\u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0431\u043e\u0438\u0434\u044b \u0432 \u043a\u0443\u0447\u0443<\/h4>\n<p>  \u0422\u0430\u043a, \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u0432 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435. \u0425\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u0451 \u0432 \u043e\u0434\u043d\u043e\u0439 \u043a\u0443\u0447\u0435 \u043d\u0435\u0445\u043e\u0440\u043e\u0448\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b\u043d\u0435\u0441\u0435\u043c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043a\u043e\u0434 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u0424\u0443\u043d\u043a\u0446\u0438\u044e \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u043e \u0442\u0430\u0439\u043c\u0435\u0440\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/MonoBehaviour.InvokeRepeating.html\">InvokeRepeating<\/a>. \u041f\u0435\u0440\u0432\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u2014 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0432\u0442\u043e\u0440\u043e\u0439 \u2014 \u0432\u0440\u0435\u043c\u044f \u0441\u0442\u0430\u0440\u0442\u0430, \u0442\u0440\u0435\u0442\u0438\u0439 \u2014 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u044f. \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0434\u043b\u044f \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432.  <\/p>\n<pre><code class=\"cs\">InvokeRepeating(&quot;CalculateVelocity&quot;, 0, 1); <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u043c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0448\u043a\u043e\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u043e\u0439 \u0438 \u0432\u044b\u0447\u0442\u0435\u043c \u0438\u0437 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0446\u0435\u043d\u0442\u0440\u0430 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0431\u043e\u0438\u0434\u0430. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u0441\u043a\u0440\u0438\u043f\u0442 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u0443\u044e (\u0441\u043a\u0430\u0436\u0443 \u043f\u043e\u0442\u043e\u043c \u0437\u0430\u0447\u0435\u043c) \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e velocity, \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0431\u043d\u0443\u043b\u0438\u043c \u0435\u0451, \u0430 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043f\u0440\u0438\u043f\u043b\u044e\u0441\u0443\u0435\u043c \u043a \u043d\u0435\u0439 \u043d\u043e\u0432\u044b\u0439 \u0432\u0435\u043a\u0442\u043e\u0440 cohesion. \u0412 Update \u043f\u0440\u0438\u043b\u043e\u0436\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043a \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430 \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438. <a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Time-deltaTime.html\">Time.deltaTime<\/a> \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0435\u043b\u043e \u043e\u0442 FPS \u0438 \u0448\u043b\u043e \u0441 \u043e\u0434\u043d\u043e\u0439 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e \u043d\u0430 \u0432\u0441\u0435\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430\u0445.  <\/p>\n<pre><code class=\"cs\">transform.position += velocity * Time.deltaTime; <\/code><\/pre>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0440\u0430\u0437 \u043d\u0430\u0448 \u0446\u0435\u043d\u0442\u0440 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0432 \u0432\u0435\u043a\u0442\u043e\u0440, \u0442\u043e \u043c\u044b \u043f\u043e\u043c\u0435\u043d\u044f\u0435\u043c \u043d\u0430\u0448 <a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Debug.DrawLine.html\">Debug.DrawLine<\/a> \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0444\u0430\u043d\u0442\u0430\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 <a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Debug.DrawRay.html\">Debug.DrawRay<\/a>. \u0420\u0430\u0437\u043d\u0438\u0446\u044b \u043d\u0438\u043a\u0430\u043a\u043e\u0439, \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0432 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u0445, \u043f\u0440\u044f\u043c \u043a\u0430\u043a \u0443 \u043d\u0430\u0441.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Boid.cs cohesion<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">using UnityEngine;  public class Boid : MonoBehaviour {     public Vector3 velocity;      private float cohesionRadius = 10;     private Collider[] boids;     private Vector3 cohesion;      private void Start()     {         InvokeRepeating(&quot;CalculateVelocity&quot;, 0, 1);     }      void CalculateVelocity()     {         velocity = Vector3.zero;         cohesion = Vector3.zero;         boids = Physics.OverlapSphere(transform.position, cohesionRadius);         foreach (var boid in boids)         {             cohesion += boid.transform.position;         }         cohesion = cohesion \/ boids.Length;         cohesion = cohesion - transform.position;         velocity += cohesion;     }      void Update()     {         transform.position += velocity * Time.deltaTime;         Debug.DrawRay(transform.position, cohesion, Color.magenta);     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/fcb\/6da\/1d9\/fcb6da1d971dc3ac77ae39dce057cc42.gif\"\/><\/p>\n<h4>\u0420\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c \u0431\u043e\u0438\u0434\u044b<\/h4>\n<p>  \u0420\u0430\u0441\u0447\u0451\u0442 separation \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435. \u041d\u0443\u0436\u043d\u043e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u043a\u0443\u0447\u0438 \u0441\u043e\u0441\u0435\u0434\u0435\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u0443\u044e \u0441\u0443\u043c\u043c\u0443 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u043e\u0442 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043e\u0441\u0435\u0434\u0430. \u0412\u0435\u043a\u0442\u043e\u0440 \u043e\u0442 \u0441\u043e\u0441\u0435\u0434\u0430 \u0434\u0435\u043b\u0438\u043c \u043d\u0430 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0434\u043e \u043d\u0435\u0433\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Vector3-magnitude.html\">Vector3.magnitude<\/a>. \u0412 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0435\u0439\u0441\u044f \u0441\u0443\u043c\u043c\u0435 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0432\u0435\u0441\u043e\u043c \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u043b\u0430\u0434\u0430\u0442\u044c \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0435 \u0441\u043e\u0441\u0435\u0434\u0438.  <\/p>\n<pre><code class=\"cs\">separation += (transform.position - boid.transform.position) \/ (transform.position - boid.transform.position).magnitude; <\/code><\/pre>\n<p>  \u0418\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0439 \u0434\u0438\u0441\u0442\u0430\u043d\u0446\u0438\u0435\u0439, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043e\u0434\u043d\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0434\u043b\u044f \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0430 \u0438 \u043e\u0434\u043d\u0443 \u0434\u043b\u044f \u0440\u0430\u0434\u0438\u0443\u0441\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f.  <\/p>\n<pre><code class=\"cs\">if ((transform.position - boid.transform.position).magnitude &lt; separationDistance) <\/code><\/pre>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043d\u0430\u043c \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u0435 \u043d\u0443\u043b\u0435\u0432\u043e\u0433\u043e \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u0432 \u0441\u0443\u043c\u043c\u0443 \u0438\u0437-\u0437\u0430 \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440\u0430 \u0441\u0430\u043c\u043e\u0433\u043e \u0431\u043e\u0438\u0434\u0430. \u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435, \u0447\u0442\u043e <a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Physics.OverlapSphere.html\">Physics.OverlapSphere<\/a> \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0432\u0441\u0435 \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440\u044b, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u043a\u043e\u043b\u043b\u0430\u0439\u0434\u0435\u0440 \u0431\u043e\u0438\u0434\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u0435.  <\/p>\n<pre><code class=\"cs\">if (boid != collider && (transform.position - boid.transform.position).magnitude &lt; separationDistance) <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Boid.cs separation<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">using UnityEngine;  public class Boid : MonoBehaviour {     public Vector3 velocity;      private float cohesionRadius = 10;     private float separationDistance = 5;     private Collider[] boids;     private Vector3 cohesion;     private Vector3 separation;     private int separationCount;      private void Start()     {         InvokeRepeating(&quot;CalculateVelocity&quot;, 0, 1);     }      void CalculateVelocity()     {         velocity = Vector3.zero;         cohesion = Vector3.zero;         separation = Vector3.zero;         separationCount = 0;          boids = Physics.OverlapSphere(transform.position, cohesionRadius);         foreach (var boid in boids)         {             cohesion += boid.transform.position;              if (boid != collider && (transform.position - boid.transform.position).magnitude &lt; separationDistance)             {                 separation += (transform.position - boid.transform.position) \/ (transform.position - boid.transform.position).magnitude;                 separationCount++;             }         }          cohesion = cohesion \/ boids.Length;         cohesion = cohesion - transform.position;         if (separationCount &gt; 0)         {             separation = separation \/ separationCount;         }          velocity += cohesion + separation;     }  \tvoid Update() \t{         transform.position += velocity * Time.deltaTime;          Debug.DrawRay(transform.position, separation, Color.green);         Debug.DrawRay(transform.position, cohesion, Color.magenta); \t} } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/bf3\/3f5\/627\/bf33f56276f0822bc65f79f2df7adfd0.gif\"\/><\/p>\n<h4>\u041e\u0440\u0433\u0430\u043d\u0438\u0437\u0443\u0435\u043c \u0431\u043e\u0438\u0434\u044b<\/h4>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0431\u043e\u0438\u0434\u044b \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0435\u0437\u0434\u0443\u043c\u043d\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u043b\u0438\u0441\u044c \u0432 \u0440\u043e\u0432\u043d\u044b\u0435 \u043a\u0443\u0447\u043a\u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u043b\u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0435\u0434\u0435\u0439. \u0420\u0430\u0441\u0447\u0451\u0442 alignment \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442, \u043c\u044b \u0441\u0443\u043c\u043c\u0438\u0440\u0443\u0435\u043c \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 velocity (\u0430\u0433\u0430!) \u043e\u0442 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043e\u0441\u0435\u0434\u0430 \u0438 \u0434\u0435\u043b\u0438\u043c \u043d\u0430 \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e. \u0414\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u0440\u0438\u0446\u0435\u043f\u043b\u0435\u043d\u043d\u044b\u043c \u0441\u043a\u0440\u0438\u043f\u0442\u0430\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/GameObject.GetComponent.html\">GameObject.GetComponent<\/a>. \u041e\u043d \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u044b, \u0430 \u0432\u043e\u043e\u0431\u0449\u0435 \u043b\u044e\u0431\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b. \u0417\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0448\u0442\u0443\u043a\u0430.  <\/p>\n<pre><code class=\"cs\">alignment += boid.GetComponent&lt;Boid&gt;().velocity; <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Boid.cs alignment<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">using UnityEngine;  public class Boid : MonoBehaviour {     public Vector3 velocity;      private float cohesionRadius = 10;     private float separationDistance = 5;     private Collider[] boids;     private Vector3 cohesion;     private Vector3 separation;     private int separationCount;     private Vector3 alignment;      private void Start()     {         InvokeRepeating(&quot;CalculateVelocity&quot;, 0, 1);     }      void CalculateVelocity()     {         velocity = Vector3.zero;         cohesion = Vector3.zero;         separation = Vector3.zero;         separationCount = 0;         alignment = Vector3.zero;          boids = Physics.OverlapSphere(transform.position, cohesionRadius);         foreach (var boid in boids)         {             cohesion += boid.transform.position;             alignment += boid.GetComponent&lt;Boid&gt;().velocity;              if (boid != collider && (transform.position - boid.transform.position).magnitude &lt; separationDistance)             {                 separation += (transform.position - boid.transform.position) \/ (transform.position - boid.transform.position).magnitude;                 separationCount++;             }         }          cohesion = cohesion \/ boids.Length;         cohesion = cohesion - transform.position;         if (separationCount &gt; 0)         {             separation = separation \/ separationCount;         }         alignment = alignment \/ boids.Length;          velocity += cohesion + separation + alignment;     }      void Update()     {         transform.position += velocity * Time.deltaTime;          Debug.DrawRay(transform.position, separation, Color.green);         Debug.DrawRay(transform.position, cohesion, Color.magenta);         Debug.DrawRay(transform.position, alignment, Color.blue);     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0438\u2026 \u043d\u043e\u043b\u044c \u0440\u0435\u0430\u043a\u0446\u0438\u0438, \u0432\u0441\u0451 \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0434\u0432\u043e\u0435\u0447\u043a\u0443 \u0432 \u0444\u043e\u0440\u043c\u0443\u043b\u0443 \u0440\u0430\u0441\u0447\u0451\u0442\u0430 velocity.  <\/p>\n<pre><code class=\"cs\">velocity += cohesion + separation + alignment*2; <\/code><\/pre>\n<p>  \u0418 \u0442\u043e\u0433\u0434\u0430\u2026<\/p>\n<p>  <a href=\"http:\/\/fotki.yandex.ru\/users\/mihtimak\/view\/648284\/?page=1\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/b35\/acd\/555\/b35acd555e4dcc2f413d634da75e9268.gif\"\/><\/a><\/p>\n<h4>\u0420\u0435\u0436\u0435\u043c \u0432\u0435\u043a\u0442\u043e\u0440\u044b<\/h4>\n<p>  \u0412\u0436\u0443\u0443\u0443\u043c! \u041d\u0443 \u0447\u0442\u043e \u0436\u0435, \u0432\u043f\u043e\u043b\u043d\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e. \u041c\u044b \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043b\u0438 \u0432\u0435\u043a\u0442\u043e\u0440 \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043b \u0432\u0435\u043a\u0442\u043e\u0440 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043b \u0432\u0435\u043a\u0442\u043e\u0440 \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439\u2026 \u041d\u0443 \u0432\u044b \u043f\u043e\u043d\u044f\u043b\u0438. \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438. \u041f\u0440\u0438\u0447\u0451\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0435\u0449\u0451 \u0438 \u043d\u0430 \u0432\u0441\u0435\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u0445 \u0432\u0435\u043a\u0442\u043e\u0440\u0430, \u0438\u043d\u0430\u0447\u0435 \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0431\u043e\u0438\u0434\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u043c. \u041c\u043e\u0436\u0435\u0442\u0435 \u0441\u0430\u043c\u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>  \u0414\u043b\u044f \u043e\u0431\u0440\u0435\u0437\u0430\u043d\u0438\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u0432 Unity \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f <a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Vector3.ClampMagnitude.html\">Vector3.ClampMagnitude<\/a>. \u041f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0432\u0438\u0434\u0430:  <\/p>\n<pre><code class=\"cs\">velocity = Vector3.ClampMagnitude(velocity, maxSpeed); <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Boid.cs clamp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">using UnityEngine;  public class Boid : MonoBehaviour {     public Vector3 velocity;      private float cohesionRadius = 10;     private float separationDistance = 5;     private Collider[] boids;     private Vector3 cohesion;     private Vector3 separation;     private int separationCount;     private Vector3 alignment;     private float maxSpeed = 15;      private void Start()     {         InvokeRepeating(&quot;CalculateVelocity&quot;, 0, 1f);     }      void CalculateVelocity()     {         velocity = Vector3.zero;         cohesion = Vector3.zero;         separation = Vector3.zero;         separationCount = 0;         alignment = Vector3.zero;          boids = Physics.OverlapSphere(transform.position, cohesionRadius);         foreach (var boid in boids)         {             cohesion += boid.transform.position;             alignment += boid.GetComponent&lt;Boid&gt;().velocity;              if (boid != collider && (transform.position - boid.transform.position).magnitude &lt; separationDistance)             {                 separation += (transform.position - boid.transform.position) \/ (transform.position - boid.transform.position).magnitude;                 separationCount++;             }         }          cohesion = cohesion \/ boids.Length;         cohesion = cohesion - transform.position;         cohesion = Vector3.ClampMagnitude(cohesion, maxSpeed);         if (separationCount &gt; 0)         {             separation = separation \/ separationCount;             separation = Vector3.ClampMagnitude(separation, maxSpeed);         }         alignment = alignment \/ boids.Length;         alignment = Vector3.ClampMagnitude(alignment, maxSpeed);          velocity += cohesion + separation * 10 + alignment * 1.5f;         velocity = Vector3.ClampMagnitude(velocity, maxSpeed);     }      void Update()     {         if (transform.position.magnitude &gt; 25)         {             velocity += -transform.position.normalized;         }          transform.position += velocity * Time.deltaTime;          Debug.DrawRay(transform.position, separation, Color.green);         Debug.DrawRay(transform.position, cohesion, Color.magenta);         Debug.DrawRay(transform.position, alignment, Color.blue);     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u0443\u0441\u043c\u0438\u0440\u0451\u043d\u043d\u044b\u0445 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/eb4\/0c3\/269\/eb40c32691c2293d2d932ddafe17916c.gif\"\/><\/p>\n<h4>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u0443\u0435\u043c<\/h4>\n<p>  \u0420\u0430\u0441\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0431\u043e\u0438\u0434\u044b \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e. \u0414\u043b\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0439 \u0440\u0430\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Object.Instantiate.html\">Instantiate<\/a>. \u041d\u0430 \u0432\u0445\u043e\u0434 \u0435\u0439 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u0434\u043b\u044f \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043d\u043e\u0432\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438 \u0435\u0433\u043e \u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435. \u0414\u043b\u044f \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u0440\u0435\u0444\u0430\u0431\u0430 \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0432 \u0438\u043d\u0441\u043f\u0435\u043a\u0442\u043e\u0440\u0435. \u0421\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0443\u0434\u043e\u0431\u043d\u043e \u0431\u0440\u0430\u0442\u044c \u0438\u0437 <a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Random-insideUnitSphere.html\">Random.insideUnitSphere<\/a>, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u043c\u043d\u043e\u0436\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0430 \u0440\u0430\u0434\u0438\u0443\u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0439 \u0441\u0444\u0435\u0440\u044b. \u041d\u0430\u0448\u0438 \u0431\u043e\u0438\u0434\u044b \u043c\u043e\u0436\u043d\u043e \u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0433\u043e\u0434\u043d\u043e, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 \u043e\u0434\u0438\u043d, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f <a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Quaternion-identity.html\">Quaternion.identity<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f.  <\/p>\n<pre><code class=\"cs\">Instantiate(boidPrefab, Random.insideUnitSphere * 25, Quaternion.identity); <\/code><\/pre>\n<p>  \u0412 \u0446\u0438\u043a\u043b\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0432\u044b\u0448\u0435 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043b\u044e\u0431\u043e\u0435 \u043d\u0443\u0436\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u043e\u0438\u0434\u043e\u0432. \u041a\u0438\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u043d\u0430 \u043f\u0443\u0441\u0442\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 \u0446\u0435\u043d\u0442\u0440\u0435 \u0441\u0446\u0435\u043d\u044b \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043f\u0440\u0435\u0444\u0430\u0431.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">HeartOfTheSwarm.cs<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">using UnityEngine;  public class HeartOfTheSwarm : MonoBehaviour {     public Transform boidPrefab;     public int swarmCount = 100;       void Start() \t{         for (var i = 0; i &lt; swarmCount; i++)         {             Instantiate(boidPrefab, Random.insideUnitSphere * 25, Quaternion.identity);         }     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u0417\u0430 \u0441\u0442\u0440\u0435\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043b\u0435\u0442\u0430\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0435\u0439 \u0431\u043e\u0438\u0434\u043e\u0432 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c, \u0445\u043e\u0440\u043e\u0448\u043e \u0431\u044b \u043f\u043e\u0441\u0430\u0434\u0438\u0442\u044c \u0438\u0445 \u043d\u0430 \u0446\u0435\u043f\u044c. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 Update \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435:  <\/p>\n<pre><code class=\"cs\">if (transform.position.magnitude &gt; 25) {     velocity += -transform.position.normalized; } <\/code><\/pre>\n<p>  \u0421 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u043e\u0438\u0434\u044b, \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0437\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u0435\u0439 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0444\u0435\u0440\u044b, \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0446\u0435\u043d\u0442\u0440\u0430. \u041d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0433\u0440\u0430\u0435\u043c\u0441\u044f \u0441 \u043c\u043d\u043e\u0436\u0438\u0442\u0435\u043b\u044f\u043c\u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u0438 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438, \u0438\u043d\u0430\u0447\u0435 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430. \u0421\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c \u043d\u0438\u0436\u0435.  <\/p>\n<pre><code class=\"cs\">velocity += cohesion + separation * 10 + alignment * 1.5f; <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c, \u043b\u044e\u0431\u0443\u0435\u043c\u0441\u044f.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Boid.cs<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">using UnityEngine;  public class Boid : MonoBehaviour {     public Vector3 velocity;      private float cohesionRadius = 10;     private float separationDistance = 5;     private Collider[] boids;     private Vector3 cohesion;     private Vector3 separation;     private int separationCount;     private Vector3 alignment;     private float maxSpeed = 15;      private void Start()     {         InvokeRepeating(&quot;CalculateVelocity&quot;, 0, 0.1f);     }      void CalculateVelocity()     {         velocity = Vector3.zero;         cohesion = Vector3.zero;         separation = Vector3.zero;         separationCount = 0;         alignment = Vector3.zero;          boids = Physics.OverlapSphere(transform.position, cohesionRadius);         foreach (var boid in boids)         {             cohesion += boid.transform.position;             alignment += boid.GetComponent&lt;Boid&gt;().velocity;              if (boid != collider && (transform.position - boid.transform.position).magnitude &lt; separationDistance)             {                 separation += (transform.position - boid.transform.position) \/ (transform.position - boid.transform.position).magnitude;                 separationCount++;             }         }          cohesion = cohesion \/ boids.Length;         cohesion = cohesion - transform.position;         cohesion = Vector3.ClampMagnitude(cohesion, maxSpeed);         if (separationCount &gt; 0)         {             separation = separation \/ separationCount;             separation = Vector3.ClampMagnitude(separation, maxSpeed);         }         alignment = alignment \/ boids.Length;         alignment = Vector3.ClampMagnitude(alignment, maxSpeed);          velocity += cohesion + separation * 10 + alignment * 1.5f;         velocity = Vector3.ClampMagnitude(velocity, maxSpeed);     }      void Update()     {         if (transform.position.magnitude &gt; 25)         {             velocity += -transform.position.normalized;         }          transform.position += velocity * Time.deltaTime;          Debug.DrawRay(transform.position, separation, Color.green);         Debug.DrawRay(transform.position, cohesion, Color.magenta);         Debug.DrawRay(transform.position, alignment, Color.blue);     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/07d\/2a0\/3af\/07d2a03af6a23ca359741583ef58b013.gif\"\/><\/p>\n<p>  \u0412\u043e\u0442 \u0438 \u0432\u0441\u0451, \u0431\u043e\u0438\u0434\u044b \u043b\u0435\u0442\u0430\u044e\u0442 \u0432 \u0441\u0432\u043e\u0435\u0439 \u043a\u043b\u0435\u0442\u043a\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u0438\u0445 \u0442\u0430\u043a \u043c\u0430\u043b\u043e! \u041f\u0440\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u0441\u043e\u0442\u043d\u0438 \u0432\u0441\u0451 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043e\u0449\u0443\u0442\u0438\u043c\u043e \u0442\u043e\u0440\u043c\u043e\u0437\u0438\u0442\u044c. \u041d\u0435 \u043c\u0443\u0434\u0440\u0435\u043d\u043e, \u0432\u0435\u0434\u044c \u043c\u044b \u043d\u0435 \u0434\u0435\u043b\u0430\u043b\u0438 \u043d\u0438 \u0435\u0434\u0438\u043d\u043e\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043a\u043e\u0434, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043c\u043e\u0433 \u0434\u0435\u0440\u0436\u0430\u0442\u044c 60 FPS \u043d\u0430 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u043e\u0438\u0434\u043e\u0432. \u0410 \u043f\u043e\u043a\u0430 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u0441\u0432\u043e\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b.<\/p>\n<p>  <a href=\"https:\/\/github.com\/BasmanovDaniil\/Boids\">\u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u043d\u0430 GitHub<\/a> | <a href=\"http:\/\/basmanovdaniil.github.io\/Boids\/\">\u041e\u043d\u043b\u0430\u0439\u043d \u0432\u0435\u0440\u0441\u0438\u044f \u0434\u043b\u044f \u043e\u0431\u043b\u0430\u0434\u0430\u0442\u0435\u043b\u0435\u0439 Unity Web Player<\/a><\/p>\n<p>  \u041c\u0438\u043d\u0438-\u0431\u043e\u043d\u0443\u0441 \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043a\u0430\u043a \u044f \u0434\u0435\u043b\u0430\u043b \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Screenshot.cs<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">using UnityEngine;  public class Screenshot : MonoBehaviour {     private int count;      void Update()     {         if (Input.GetButtonDown(&quot;Jump&quot;))         {             InvokeRepeating(&quot;Capture&quot;, 0.1f, 0.3f);         }     }      void Capture()     {         Application.CaptureScreenshot(Application.dataPath + &quot;\/Screenshot&quot; + count + &quot;.png&quot;);         count++;     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/182382\/\"> http:\/\/habrahabr.ru\/post\/182382\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t<img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/f8c\/268\/1a1\/f8c2681a18cf9cd6e5265f4fa2aca240.gif\"\/><\/p>\n<p>  \u0417\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u043b\u0438 \u0432\u044b \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u043e \u0442\u043e, \u043f\u043e\u0447\u0435\u043c\u0443 \u043f\u0442\u0438\u0446\u044b \u043b\u0435\u0442\u0430\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0441\u0442\u0430\u044f\u043c\u0438 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0438 \u043d\u0435 \u043a\u043e\u043b\u043b\u0430\u043f\u0441\u0438\u0440\u0443\u044e\u0442 \u0432 \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u0439 \u0433\u0430\u043b\u0434\u044f\u0449\u0438\u0439 \u043f\u0435\u0440\u044c\u0435\u0432\u043e\u0439 \u043a\u043e\u043c? \u0425\u043c, \u0435\u0441\u043b\u0438 \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c, \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043a\u0440\u0443\u0442\u043e. \u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043e\u0434\u043d\u0430\u0436\u0434\u044b \u0432 1986 \u043d\u0430\u0448\u0451\u043b\u0441\u044f \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u043f\u043e \u0438\u043c\u0435\u043d\u0438 <a href=\"http:\/\/www.red3d.com\/cwr\/index.html\">\u041a\u0440\u0435\u0439\u0433 \u0420\u0435\u0439\u043d\u043e\u043b\u044c\u0434\u0441<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0448\u0438\u043b \u0441\u043e\u0437\u0434\u0430\u0442\u044c <a href=\"http:\/\/www.red3d.com\/cwr\/boids\/\">\u043f\u0440\u043e\u0441\u0442\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043f\u0442\u0438\u0446 \u0432 \u0441\u0442\u0430\u044f\u0445 \u0438 \u043d\u0430\u0437\u0432\u0430\u043b \u0435\u0451 Boids<\/a>. \u0412 \u043c\u043e\u0434\u0435\u043b\u0438 \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0431\u043e\u0438\u0434\u0430 \u0435\u0441\u0442\u044c \u0442\u0440\u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043f\u0440\u0430\u0432\u0438\u043b\u0430: Separation, Alignment \u0438 Cohesion. \u041f\u0435\u0440\u0432\u043e\u0435 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0438\u0437\u0431\u0435\u0433\u0430\u043d\u0438\u0438 \u0441\u0442\u043e\u043b\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u0441 \u0441\u043e\u0441\u0435\u0434\u044f\u043c\u0438, \u0432\u0442\u043e\u0440\u043e\u0435 \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043b\u0435\u0442\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432 \u0442\u0443 \u0436\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0447\u0442\u043e \u0438 \u0441\u043e\u0441\u0435\u0434\u0438, \u0430 \u0442\u0440\u0435\u0442\u044c\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0435 \u043b\u0435\u0442\u0430\u0442\u044c \u0432 \u043e\u0434\u0438\u043d\u043e\u0447\u043a\u0443 \u0438 \u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f \u0433\u0440\u0443\u043f\u043f\u044b. \u042d\u0442\u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0441\u0442\u0430\u0438 \u043f\u0442\u0438\u0446, \u0440\u044b\u0431 \u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u0436\u0438\u0432\u043d\u043e\u0441\u0442\u0438, \u0447\u0435\u043c \u0438 \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u043a\u0438\u043d\u043e \u0438 \u0438\u0433\u0440\u043e\u0432\u043e\u0439 \u0438\u043d\u0434\u0443\u0441\u0442\u0440\u0438\u0438.<\/p>\n<p>  \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435. \u0414\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e <a href=\"http:\/\/unity3d.com\/\">Unity<\/a> \u0438 C#, \u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0432\u0435\u0449\u0435\u0439 \u0432\u0435\u0440\u043d\u044b \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u0434\u0432\u0438\u0436\u043a\u043e\u0432 \u0438 \u044f\u0437\u044b\u043a\u043e\u0432. \u0412 \u044d\u0442\u043e\u043c \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435 \u044f \u043d\u0435 \u0440\u0430\u0437\u0436\u0451\u0432\u044b\u0432\u0430\u044e \u043e\u0441\u043d\u043e\u0432\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Unity, \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435 \u044d\u0444\u0444\u0435\u043a\u0442 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 Ctrl+Shift+N \u043d\u0430 \u0441\u0446\u0435\u043d\u0435, \u0443\u043c\u0435\u0435\u0442\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0438\u043d\u0441\u043f\u0435\u043a\u0442\u043e\u0440\u043e\u043c, \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0434\u0432\u0438\u0433\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b. \u0415\u0441\u043b\u0438 \u043d\u0435\u0442, \u0442\u043e \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u043d\u0430\u0447\u0430\u0442\u044c <a href=\"http:\/\/habrahabr.ru\/post\/167509\/\">\u0441 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438<\/a>. \u0418\u043b\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438.  <\/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-182382","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/182382","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=182382"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/182382\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=182382"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=182382"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=182382"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}