Hi everyone!
I’m an Unreal Engine beginner, so apologies if this is a basic question—I’m still learning the ropes.
I’m using the FPS blueprint, and I want to implement a zoom mechanic where the player can zoom in and out using the right mouse button (RMB). Pressing RMB should trigger a “camera zoom” sound while the camera zooms in, and releasing RMB should play a “zoom out” sound while the camera returns to its original FOV. The zooming animation takes 3 seconds in both directions.
Here’s the problem:
If I press and release RMB quickly (e.g., within 1 second), the “zoom out” sound still plays in its entirety, even though the zoom animation has already finished.
Questions:
How can I adjust my blueprint to stop the “zoom out” sound when the animation ended?
(Optional) Is it possible to sync the sound with the animation? For example, if the zoom-in animation reaches 20% and I release RMB, can the zoom-out sound start from a point corresponding to that animation progress (e.g., at -20%)?
I’ve attached my current blueprint setup for reference. Any guidance would be greatly appreciated. Thank you!
You can use the return value from the sound spawns, and use “Set Active” nodes to deactivate them with a false bool. Also, you want to make sure they Auto Destroy or you’ll end up with a ton of them stacking up.
Then you can either use an event from the timeline to do the stopping or check for thresholds on the float to end the sound.
Hope this helps!
Edit: Okay, I ran into a small issue—everything works fine, but when the timeline plays in its entirety, I get this error:
Blueprint Runtime Error: “Accessed None trying to read property CallFunc_SpawnSound2D_ReturnValue_1”. Node: Set Active Graph: EventGraph Function: Execute Ubergraph BP First Person Character Blueprint: BP_FirstPersonCharacter
My first thought would be that the Timeline is longer than the sound! If this is the case, and it’s auto destroyed, it will destroy the sound before the timeline can set it active or not. You can use an “IsValid” check to make sure to get rid of that error!