Download

Attach audio to velocity?

I’m trying to have an audio source go from 0 to full volume based on velocity, but I have no clue how to really do that. I have a physics constraint that I’m getting get angular velocity of in the Z axis that I’d like to affect the volume, I have a blueprint set up but can’t test it yet (I don’t have a Vive at home.) Could anyone tell me if I’m even close or if I’m way off?
f5e42535f19e55d2464e4304a21922b8a922d2a7.jpeg

You seem to be on the right track. You might need to normalize the velocity down to a 0 to 1 range before plugging it into your Adjust Volume function, though.

Thanks for the reply! So like this?

Actually nvm I think this is it:

Better, but your velocity probably isn’t in the range of 0 to 1. I’d feed the velocity value into a print string so you can get an idea of where it’s peaking. You want to set the Range Max around peak velocity.

Nice! I’ll test this out on Monday, thanks for the help!

Well I tried to test this but for some reason my sound even when on “auto-activate” wont play, but here’s the blueprint for it, technically should work. Anyone know why a sound cue won’t play?

Audio components begin playing automatically, and will continue to play as long as your cue is set to looping. Put a Print String after your Set Volume Multiplier and plug the float from your Normalize function into it to make sure it’s not reading zero.

Ok thanks man, I’ll check tomorrow. I can see the print string on a developer build of my game right?

Ya it’s just giving me 0’s, do you know what would be causing that?

It’s hard to say without knowing how you’ve got everything set up. Can you show us what your physics constraint is and how you’re moving it?

I actually switched the “get” from the physics constraint to the handle it’s affecting, which has physics on it. This gave me values when I interacted with it. I plugged the values into the normalize (it was capping at 5) but it still isn’t playing any audio, which I don’t understand.

You need to break things up and make sure each part is working independently. When you drop an audio component into a Blueprint and link it to a looped audio cue, it should begin playing automatically without any code whatsoever. If you’d done that and it’s not playing sound, then you know you’ve got a problem with your audio component. If it plays fine up until you hook up your **Play **and Set Volume Multiplier functions, then you know one of those functions is breaking it.

Also, make sure you have attenuation set up on your audio component.