---
title: "Movables Sound Component"
---
In Class: `MovablesSoundComponent`

This Component is an Actor Component to designed to be attached to Actors that generate Sounds based on their physical movement. This includes standalone objects like a ball or components like drawers in cabinet. 


**Detecting Hit and Slide Movements** 

When one object hit another, we expect it to make some kind of hit sound, depending on their qualities (size, material, surface texture etc.) and the hit velocity. A special case is dragging an object across a surface. Although this causes repetitive hits, we don't expect the Hit Sound to be played repetitively but a dedicated "slide sound".
To check wether a Hit Event from the simulation should trigger a Hit Sound or a Slide Sound, we can use the velocity vector of the hit component and compare it to to the Hit Normal Vector. When we slide across a surface, the velocity is perpendicular to the impact normal. Using acosd, you can convert the dot product to an angle, which can be easier to work with. Based on an Angle Threshold, you can decide whether a slide should be considered a slide.


::: {.callout-note}
## A thought
Now that I'm writing it down, you could also make the Threshold depending on the velocity, resulting in slow movements to be more susceptible to "clonks".
:::


**Infinite Loops** 

Creating slide sounds involves looping sounds without noticeable repeats. There are several ways to create looping sounds from non-looping sounds. For the DAW [Reaper](https://www.reaper.fm/) that I use for everything audio-related features, there is a helpful [script by X-Raym](https://www.youtube.com/watch?v=yjGDW4wVkEQ) available that automates this process from a time selection.


```{=html}
<iframe width="100%" height="500" src="https://blueprintue.com/render/a6syaqcp/" scrolling="no" allowfullscreen></iframe>
```


