{"id":3212,"date":"2020-12-18T10:23:24","date_gmt":"2020-12-18T01:23:24","guid":{"rendered":"https:\/\/blog.criware.com\/?p=3212"},"modified":"2020-12-18T10:28:51","modified_gmt":"2020-12-18T01:28:51","slug":"efficient-dynamic-impacts-with-adx2-and-ue4","status":"publish","type":"post","link":"https:\/\/blog.criware.com\/index.php\/2020\/12\/18\/efficient-dynamic-impacts-with-adx2-and-ue4\/","title":{"rendered":"Efficient Dynamic Impacts with ADX2 and UE4"},"content":{"rendered":"<p>\nIn <a href=\"https:\/\/blog.criware.com\/index.php\/2019\/11\/22\/creating-dynamic-impacts-sounds-in-unity-using-adx2\/\">a previous blog<\/a>, we looked at creating dynamic impacts in Unity. The aim was to design a highly responsive surface scrape and impact system for a marble run game. Since that use-case only involved one ball, we could use a more sophisticated AISAC layering approach, affording a higher number of voices. However, this isn\u2019t very efficient when dealing with loads of simultaneous interactions.\n<\/p>\n<p>\nIn this blog, we will look at playing impacts based on relative velocity but using ADX2\u2019s Game Variable feature. This feature works similarly to the Selector Label system but with numbers rather than text. This approach is far more intuitive when deriving gameplay information from numbers, such as a velocity.\n<\/p>\n<div style=\"max-width: 800px; margin: 0 auto; margin-bottom: 20px;\">\n<div style=\"width: 800px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-3212-1\" width=\"800\" height=\"450\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/12\/2020-12_DynamicImpact.mp4?_=1\" \/><a href=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/12\/2020-12_DynamicImpact.mp4\">https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/12\/2020-12_DynamicImpact.mp4<\/a><\/video><\/div>\n<\/div>\n<p><\/p>\n<div style=\"max-width: 800px; margin: 0 auto; margin-bottom: 20px; text-align:center;\"><a style=\"display: inline-block; border: 1px solid #ccc; padding: 20px;\" href=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/12\/2020-12_DynamicImpact.zip\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1813\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2018\/06\/zip.png\" alt=\"zip\" width=\"80\" height=\"78\" style=\"\n    display: block;\n    margin: 0 auto;\n\">2020-12_DynamicImpact.zip<\/a>\n<\/div>\n<p><em>This project was created using CRI Atom Craft Ver.3.44.13 and UE4.25<\/em><\/p>\n<h2 style=\"font-size: 150%; font-weight: bold; margin-top: 40px;\">Design in Atom Craft<\/h2>\n<p>\nTo create a similar dynamic range, we will need more samples. However, the quantity will change depending on the project requirements. For this demonstration, we have used 9, to show that even by playing one voice at a time, we can still create a convincingly nuanced range. To begin, lets:<\/p>\n<ul>\n<li>Create a new Game Variable called \u201cImpactForce\u201d<\/li>\n<li>Create a new Switch Cue named \u201cImpact\u201d\n<ul>\n<li>Drag in the relevant Waveform Materials<\/li>\n<li>In the Inspector with the Switch Tab highlighted\n<ul>\n<li>Set Switch Variable = ImpactForce<\/li>\n<li>Select the \u201cEvenly\u201d button to assign the ranges automatically<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>Open up Session Window and test playback\n<ul>\n<li>(Open up the Game Variable tab and enable ImpactForce)<\/li>\n<\/ul>\n<\/li>\n<li>Build project files for importing into UE4<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/12\/2020-12_DynamicImpact-1.png\" alt=\"2020-12_DynamicImpact-1\" width=\"1102\" height=\"513\" class=\"alignnone size-full wp-image-3219\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/12\/2020-12_DynamicImpact-1.png 1102w, https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/12\/2020-12_DynamicImpact-1-300x140.png 300w, https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/12\/2020-12_DynamicImpact-1-768x358.png 768w, https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/12\/2020-12_DynamicImpact-1-1024x477.png 1024w\" sizes=\"auto, (max-width: 1102px) 100vw, 1102px\" \/><\/p>\n<h2 style=\"font-size: 150%; font-weight: bold; margin-top: 40px;\">Implementation in UE4<\/h2>\n<p>\nTo test our system out, let\u2019s create an FPS template project. After setting up ADX2 on the engine-side and importing our build files, we can implement our audio.<\/p>\n<p>\nAll the logic we need to implement can be done on the <i>FirstPersonProjectile<\/i> Blueprint. Since the velocity and actor location is being used to add an impulse to the collided object, we also have all the gameplay information we need.\n<\/p>\n<p>\nFrom the <i>Get Velocity, <\/i>we can convert this Vector to a normalized float value using <i>Vector Length<\/i>. Essentially, this gives us the absolute velocity. We can then divide this by getting the <i>Max Speed <\/i>of the projectile to determine a relative velocity. Using <i>Max Speed <\/i>avoids the need to do arbitrary scaling since if the projectile hits at its maximum speed, it will play the most intense sample. It also conveniently means we return a value between 0 and 1. We can then use Atom\u2019s <i>Set Game Variable by Name<\/i><i><b> <\/b><\/i>function, copying the name we set in Atom Craft, \u201cImpactForce.\u201d And finally, we can spawn our sound using the actor\u2019s location already provided before destroying the projectile. The correct sound will automatically play thanks to the Game Variable setting.\n<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/12\/2020-12_DynamicImpact-2.png\" alt=\"2020-12_DynamicImpact-2\" width=\"1835\" height=\"643\" class=\"alignnone size-full wp-image-3220\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/12\/2020-12_DynamicImpact-2.png 1835w, https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/12\/2020-12_DynamicImpact-2-300x105.png 300w, https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/12\/2020-12_DynamicImpact-2-768x269.png 768w, https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/12\/2020-12_DynamicImpact-2-1024x359.png 1024w\" sizes=\"auto, (max-width: 1835px) 100vw, 1835px\" \/><\/p>\n<p>\nWe can then experiment with different velocities by changing the <i>Initial Speed<\/i> in the Projectile component\u2019s Details tab. Shooting at boundaries and from different distances will have a natural reductive effect on the projectiles\u2019 velocities. These effects are demonstrated in the demo video at the top.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In a previous blog, we looked at creating dynamic impacts in Unity. The aim was to design a highly responsive<\/p>\n","protected":false},"author":2,"featured_media":3217,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[5,7],"tags":[],"class_list":["post-3212","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-adx","category-tutorials"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/posts\/3212","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/comments?post=3212"}],"version-history":[{"count":6,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/posts\/3212\/revisions"}],"predecessor-version":[{"id":3224,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/posts\/3212\/revisions\/3224"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/media\/3217"}],"wp:attachment":[{"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/media?parent=3212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/categories?post=3212"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/tags?post=3212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}