{"id":451,"date":"2017-07-07T19:11:37","date_gmt":"2017-07-07T18:11:37","guid":{"rendered":"http:\/\/documentation.particleflocker.com\/?post_type=docs&#038;p=451"},"modified":"2017-07-07T19:11:37","modified_gmt":"2017-07-07T18:11:37","slug":"per-particle-expression","status":"publish","type":"docs","link":"https:\/\/documentation.particleflocker.com\/?docs=particle-flocker-user-guide\/system-components\/particleflocker\/attribute-output-types\/per-particle-expression","title":{"rendered":"Per-Particle Expression"},"content":{"rendered":"<p>Per-particle expressions are a way to assign a value to each particle in the simulation using a program known as an expression. You can read all about particle expressions in the Maya documentation here:<\/p>\n<p><a href=\"https:\/\/knowledge.autodesk.com\/support\/maya\/learn-explore\/caas\/CloudHelp\/cloudhelp\/2017\/ENU\/Maya\/files\/GUID-F7BE65C4-CDA4-42DC-A0D8-72B9D984B3E1-htm.html\">https:\/\/knowledge.autodesk.com\/support\/maya\/learn-explore\/caas\/CloudHelp\/cloudhelp\/2017\/ENU\/Maya\/files\/GUID-F7BE65C4-CDA4-42DC-A0D8-72B9D984B3E1-htm.html<\/a><\/p>\n<p>Using particle expressions requires some amount of technical knowledge, however once you have mastered expressions, there is virtually no limit to the types of behaviours you can implement.<\/p>\n<p>Using this powerful system, Particle Flocker allows you to create expressions which control a specific Particle Flocker attribute. This opens up a world of possibilities such as being able to create interesting procedural flock movements or being able to assign special behaviour to an individual flock member.<\/p>\n<p>To create a per-particle expression you need to press the <strong>New Expression<\/strong> button in the Particle Flocker Window:<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-442\" src=\"http:\/\/documentation.particleflocker.com\/wp-content\/uploads\/NewExpression.jpg\" alt=\"\" width=\"489\" height=\"289\" srcset=\"https:\/\/documentation.particleflocker.com\/wp-content\/uploads\/NewExpression.jpg 489w, https:\/\/documentation.particleflocker.com\/wp-content\/uploads\/NewExpression-300x177.jpg 300w\" sizes=\"(max-width: 489px) 100vw, 489px\" \/><\/p>\n<p>Pressing this button will display a pop-up menu with 3 options:<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-443\" src=\"http:\/\/documentation.particleflocker.com\/wp-content\/uploads\/ExpressionType.jpg\" alt=\"\" width=\"289\" height=\"62\" \/><\/p>\n<p>These are standard Maya particle expression types. You can read about them in the <a href=\"https:\/\/knowledge.autodesk.com\/support\/maya\/learn-explore\/caas\/CloudHelp\/cloudhelp\/2017\/ENU\/Maya\/files\/GUID-F7BE65C4-CDA4-42DC-A0D8-72B9D984B3E1-htm.html\">Maya documentation<\/a>. However in a nutshell, they can be described as follows:<\/p>\n<h4>Creation Expression<\/h4>\n<p>Executed once at the start of a simulation and not updated again. Ideal if you want the expression to control the initial state of the particles<\/p>\n<h4>Runtime Before Dynamics Expression<\/h4>\n<p>Executed every frame before any dynamics calculations are performed. This type of expression is used if you want the expression to change during the simulation, such as ramping up a value over time.<\/p>\n<h4>Runtime After Dynamics Expression<\/h4>\n<p>Same as the before dynamics version, except that the expression is calculated after all dynamics is performed.<\/p>\n<h3>Example<\/h3>\n<p>Here is a simple example of a per-particle expression which modifies the <em>Maximum Speed<\/em> attribute over time, making particles appear to wait their turn before starting to move. This may be useful if you want to have birds taking flight one after another:<\/p>\n<pre>proc float getSpeed()\r\n{\r\n    \/\/ Use the current particle's ID and the current frame \r\n    \/\/ to decide if this particle should start to move or not\r\n    if(frame &gt; (nParticleShape1.particleId * 4))\r\n        return 10;\r\n    return 0;\r\n}\r\nnParticleShape1.particleFlocker_maximumSpeed = getSpeed();<\/pre>\n<p>The above example expression must be set as a Runtime expression (Before or after dynamics).<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":283,"menu_order":2,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"doc_tag":[],"_links":{"self":[{"href":"https:\/\/documentation.particleflocker.com\/index.php?rest_route=\/wp\/v2\/docs\/451"}],"collection":[{"href":"https:\/\/documentation.particleflocker.com\/index.php?rest_route=\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/documentation.particleflocker.com\/index.php?rest_route=\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/documentation.particleflocker.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/documentation.particleflocker.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=451"}],"version-history":[{"count":1,"href":"https:\/\/documentation.particleflocker.com\/index.php?rest_route=\/wp\/v2\/docs\/451\/revisions"}],"predecessor-version":[{"id":452,"href":"https:\/\/documentation.particleflocker.com\/index.php?rest_route=\/wp\/v2\/docs\/451\/revisions\/452"}],"up":[{"embeddable":true,"href":"https:\/\/documentation.particleflocker.com\/index.php?rest_route=\/wp\/v2\/docs\/283"}],"prev":[{"title":"Random Between 2 Values","link":"https:\/\/documentation.particleflocker.com\/?docs=particle-flocker-user-guide\/system-components\/particleflocker\/attribute-output-types\/random-between-2-values","href":"https:\/\/documentation.particleflocker.com\/index.php?rest_route=\/wp\/v2\/docs\/449"}],"wp:attachment":[{"href":"https:\/\/documentation.particleflocker.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=451"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/documentation.particleflocker.com\/index.php?rest_route=%2Fwp%2Fv2%2Fdoc_tag&post=451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}