Having trouble with audio stopping at a level without errors

This was going to be another question but I found the answer has already been answered. The problem is, I get the same error message as they did but their solution does not work for me (I might be forgetting a step or 2) I found out somewhat the answer to my question here I basically have the exact same setup as them (in terms of blueprints and want)

Basically I have main menu playing that crosses over if you say go to options, level select etc. But I want it to stop once the player is in level 1 map. And just to confirm (if Iā€™m doing it right)

Here is my game instance that makes the audio carry over to other maps

This is the Level1 Level Blueprint


So Iā€™ve attempted with both the event beginplay and the custom event. When I use Eventplay I got the same error message as the user in the other post

ā€œBlueprint Runtime Error: ā€œAccessed None trying to read property MainMenuTrackā€. Node: Stop Graph: EventGraph Function: Execute Ubergraph Level 1 Blueprint: Level1ā€

The annoying thing is, it works xD it stops the audio (just not for the reason its been setup for). The OP asked about it and was told they were not using the correct variable/component but then OP said they created a custom event and it all worked.

I am 99% sure I am using the correct variable/component, when I select ā€œAs Custom Game Instanceā€ from the ā€œcast to CustomGameInstanceā€ node I type it ā€œget Main Menu Trackā€ which then creates a middle node ā€œTarget and Main Menu Trackā€ then gets plugged into the target of the stop function.

So I have a custom event as seen in the blueprint, when I do this no more error messages but the music doesnā€™t stop. So perhaps I misunderstood something, or there is another step that Iā€™ve not added in, as I am still pretty new to UE so hopefully Iā€™ve remembered to explain everything required.

The error means the variable ā€˜main menu trackā€™ in your game instance is not assigned to anything.

The code looks fine BTW, but somehowā€¦ you are not using the same variable.

Have you specified your game instance in the project settings? Is that cast working? ( put a print string on it ).

1 Like

Unreal-Engine-issue

Thatā€™s super odd because its the only ā€œmain menu musicā€ component Iā€™ve got. Unless Iā€™m doing something wrong here (I believe I canā€™t in this instance?)

(Did a zoomed up version if its a bit hard to see)
2023-11-26-11-04-43

Yes I believe I do, just to confirm. This was the first image in my first post

Like I say, it looks fine :slight_smile:

Try a print string on the cast to make sure itā€™s working.

Accessed none, is what it says, Iā€™m afraidā€¦

1 Like

Alright, is this the correct way to do it (we are just wanting to see if the command itself is getting executed?


From what I can tell, as you said Itā€™s not using the actual audio component, yet I have 0 in my Level BPā€¦ so Iā€™m not sure where the 2nd and 3rd one even existā€¦

Try a print string here

That will tell you if the cast is failingā€¦

1 Like

Okay updated Level BP

Got ā€œNone_Audiocomponent_1 MainMenuā€

I then noticed I had stop still hooked up to the print string thing, so updated it to this

And I got no message on screen, but still error message.

Switched from Event BeginPlay to Custom

No print message or error either.

1 Like

This is strange.

So, weā€™ve covered quite a lot, you do have the correct GI, it does have the variable, but apparently that variable is not getting set.

That means this

has not run by the time you come to stop the sound. Orā€¦ it has run more than once.

Is that possible somehow?..

1 Like

Not gonna lie, Iā€™m mega confused hahaha

If Iā€™m understanding correctly it has run before level 1 (basically goes Main Menu>Level Map>Player clicks on Level 1>Level 1 Map.

Iā€™m not sure what else I can show to see what else could be causing issues. Sorry if this is basically spamming you but its just to hopefully help you get the idea of the project without it being in front of you.

(Main Menu - Level BP)

(Level Select Map)

I am thinking because I made a new game instance, does that override the level 1 game instant, where it could go to say the default game instant in level 1 and in theory that would stop the audio from crossing over to that level (might be a bit off I assume though).

1 Like

Iā€™m not seeing it :melting_face:

No. The whole point of the GI, is there is only one, and it lives between levels.

So the idea is

  1. Custom GI ( you have )
  2. In the menu, play the music from the GI
  3. Click around the menus
  4. Eventually, open level X ( all this time, the music should still be playing )
  5. In the level BP of level X, you can say

and it should stop the music.

Possible errors are

  1. It does stop the music and get ā€˜noneā€™ errors ā†’ you have stopped it more than once
  2. It does stop the music and no other errors ā†’ itā€™s working
  3. It does not stop the music and you get ā€˜noneā€™ errors ā†’ somehow you have cleared the variable, or used a variable with the same name or something strangeā€¦
1 Like

Correct, thats how Iā€™ve got it setup and does all that keeps playing when level x has been loaded in. Basically sounds like #3, but Iā€™ve not used a variable with the same name or anything.

I made a video to show the game. Hopefully something sticks out and is causing the issue. Let me know if you want me to record a certain section.
(I did open some things that wonā€™t be of any help I donā€™t think, Iā€™ve just woken up and trying to get my head around the project again - trying to remember where I had the Custom Game Instance).

Video

I have one more theory: ( drum rollā€¦ )

You have more than one BP called ā€˜custom game instanceā€™. And you have picked the wrong one somewhere.

If thatā€™s not the case, then what you can do, is just zip up the project, put it somewhere like google docs and send me a link. I will take a look :slight_smile: ( you can PM me the link )

1 Like

Nah just got the one custom game instance and only one file named that. Will send DM soon.

1 Like

So turns out (for whatever reason) because I was loading from Level 1 map and going back through the menuā€™s to get the music playing from main menu it would give me the error when if I start from the main menu map (which it will be like that in game) it doesnā€™t give me the error message.

I had done it in the past but thought it was wrong so I disconnected nodes and such trying to figure it out but I needed both the event beginplay and custom event plugged into ā€œcast to customgameinstanceā€.

Massive thanks to @ClockworkOcean

1 Like