How to fix accessed none blueprint runtime Error for spawning sound at location?

Hi there,

I’m having some trouble with my blueprint, I have managed to set up a point light that turns on and off when I press E on a nearby light switch. Along with this I have also set up a sound cue that spawns a simple light bulb buzzing noise that also turns on and off with the light switch.

It works exactly as I need it to, except I get the blueprint runtime error "accessed none trying to read property Light Buzz. I know that this is because I have an audio component variable named “Light Buzz” that has a value of none when the lights are off, so it’s trying to stop playing a sound that just simply doesn’t exist yet.

Anyway I have been trying all kinds of arrangements today with various nodes but I cannot for the life of me figure out how to set this up. I just want to be able to flick the sound on and off with the lights. I’ve also been all over the internet today to try and find an answer but most tell me why the runtime error is happening but not how to fix it in this particular situation.

If anybody has a solution or could point me in the right direction the help would be very much appreciated. I’ll post photos of the set-up below
thank-you

This is the event graph for the point light blueprint:

This is where I set up the sound of the point light blueprint. As you can see when the boolean “light is on” is true it spawns a sound at the location of the point light and then sets the audio component variable. Which is just the problem. When the boolean is false it stops playing the sound since the light is off to start it has no information set in the “light buzz” audio component.

This is the light switch blueprint in case you want to see that as well (The custom switch light function is just an exact copy of the point light blueprint only it’s been made into a function):

Use an IsValid node to turn the sound off:

image

Ahhh yes that worked like a charm, and with minimal effort. Thank-you for your assistance.

1 Like