I’ve been trying to get the values of a rotation to an audiosource so that I can get a value which will effect the filter. Here is what I’m trying to do.
Facing left would also be ninety degrees and facing away would be 180. I want to get all relative float values when my player camera is nearing or headed away from the sound source.
I have figured out how to get values relative to it’s angle so imagine the principle is very much the same in terms of getting the values I want. Anybody know of a way to get these rotation values no matter where my player is in the worldspace?
(Code for distance-angle)
float angle = Mathf.Atan2(v.y, v.x) * Mathf.Rad2Deg;
if(angle > 90){
float reverseAngle = (90 - angle) + 90;
lowPass.cutoffFrequency = (reverseAngle/180 * 22000);
}
if(angle < 90){
lowPass.cutoffFrequency = (angle/180 * 22000);
}