{"id":6105,"date":"2025-07-02T16:14:21","date_gmt":"2025-07-02T07:14:21","guid":{"rendered":"https:\/\/blog.criware.com\/?p=6105"},"modified":"2025-08-06T17:31:14","modified_gmt":"2025-08-06T08:31:14","slug":"adx-unity-synchronization-part-2","status":"publish","type":"post","link":"https:\/\/blog.criware.com\/index.php\/2025\/07\/02\/adx-unity-synchronization-part-2\/","title":{"rendered":"ADX &#038; Unity Synchronization [Part 2]"},"content":{"rendered":"<p><a href=\"https:\/\/blog.criware.com\/index.php\/2025\/06\/26\/adx-unity-synchronization-part-1\/\">In the first part<\/a> of this tutorial, we saw a simple way to synchronize the display of the subtitles with the playback of audio dialog. In this post, we will introduce synchronization based on Cue markers, allowing us to shake the camera and door in Unity in response to audio events.<\/p>\n<p><center><div style=\"width: 640px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-6105-1\" width=\"640\" height=\"360\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2025\/07\/video.mp4?_=1\" \/><a href=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2025\/07\/video.mp4\">https:\/\/blog.criware.com\/wp-content\/uploads\/2025\/07\/video.mp4<\/a><\/video><\/div><\/center><\/p>\n<h5>Setting up the Cue<\/h5>\n<p>First, we prepare a Cue in AtomCraft with several Waveform Regions on the timeline, each one corresponding to a knock on the door.  Then, we add a Marker at the beginning of each sound, as shown in the diagram below.<\/p>\n<p><center><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2025\/07\/markers.png\" alt=\"\" width=\"651\" height=\"289\" class=\"alignnone size-full wp-image-6111\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2025\/07\/markers.png 869w, https:\/\/blog.criware.com\/wp-content\/uploads\/2025\/07\/markers-300x133.png 300w, https:\/\/blog.criware.com\/wp-content\/uploads\/2025\/07\/markers-768x341.png 768w\" sizes=\"auto, (max-width: 651px) 100vw, 651px\" \/><\/center><\/p>\n<h5>Scripting<\/h5>\n<p>In Unity, the <strong>OnCallback<\/strong> function provided by the <strong>CriAtomExSequencer<\/strong> class will allow us to be notified when the position of a Marker is reached during the playback of our Cue. In the script below, we retrieve the <strong>CriAtomSource<\/strong> attached to the object, play it every 5 seconds, and then output some info with Debug.Log when a Marker is reached.<\/p>\n<p><center><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2025\/07\/code.png\" alt=\"\" width=\"822\" height=\"800\" class=\"alignnone size-full wp-image-6112\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2025\/07\/code.png 822w, https:\/\/blog.criware.com\/wp-content\/uploads\/2025\/07\/code-300x292.png 300w, https:\/\/blog.criware.com\/wp-content\/uploads\/2025\/07\/code-768x747.png 768w\" sizes=\"auto, (max-width: 822px) 100vw, 822px\" \/><\/center><\/p>\n<p>*Note that the <strong>SetEventCallback()<\/strong> function used with previous versions of the CRIWARE plug-in is now deprecated.<\/p>\n<h5>Animation<\/h5>\n<p>In our sample scene, as shown below, we associate a vibrating animation with the door, which is played each time it receives a trigger called \u201cImpact\u201d.<\/p>\n<p><center><div style=\"width: 640px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-6105-2\" width=\"640\" height=\"360\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2025\/07\/video_door.mp4?_=2\" \/><a href=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2025\/07\/video_door.mp4\">https:\/\/blog.criware.com\/wp-content\/uploads\/2025\/07\/video_door.mp4<\/a><\/video><\/div><\/center><\/p>\n<p>On the script side, we simply need to call <strong>animator.SetTrigger(&#8220;Impact&#8221;);<\/strong> in the body of the callback function to make the door shake when a Marker is reached during the playback of the ADX Cue. <\/p>\n<p>For the camera, we used the following script that relies on Perlin noise to achieve a more natural shaking movement. <a href=\"https:\/\/github.com\/keijiro\/Reaktion\/blob\/master\/Assets\/Reaktion\/Utility\/JitterMotion.cs\">https:\/\/github.com\/keijiro\/Reaktion\/blob\/master\/Assets\/Reaktion\/Utility\/JitterMotion.cs<\/a><\/p>\n<p>We modified the code to cause temporary random shakes rather than a sustained jitter.<br \/>\nOf course, for a more dramatic effect, you could also use Unity particles and prefabs to make small debris fall from the walls and ceiling.<\/p>\n<p>By itself, ADX is capable of some impressive work, such as playing back a large number of voices with a very low CPU load. However, the sense of immersion and realism in your game can be greatly improved when the audio and other systems, such as animation and VFX, are synchronized. We hope this 2-part tutorial gave you some ideas for your own games!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the first part of this tutorial, we saw a simple way to synchronize the display of the subtitles with<\/p>\n","protected":false},"author":2,"featured_media":6109,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[5,7,23],"tags":[],"class_list":["post-6105","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-adx","category-tutorials","category-unity"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/posts\/6105","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=6105"}],"version-history":[{"count":14,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/posts\/6105\/revisions"}],"predecessor-version":[{"id":6124,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/posts\/6105\/revisions\/6124"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/media\/6109"}],"wp:attachment":[{"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/media?parent=6105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/categories?post=6105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/tags?post=6105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}