Projectile And Music Problems After Death or Restart [Solved]

Edge123

  • Posts: 42
I've been having problems with my music being unable to play sometimes after the player dies or restarts a scene. Another problem is during the boss fight, the boss is suppose to shoot projectiles at the player, but when the player dies during the fight, it restarts to the projectiles being created and staying where it was created. This goes for the player as well since they are suppose to shoot at the boss. This is the code I have if it's helpful.

https://imgur.com/RsJE2kj
This is when the player gets killed by any dangers. The code is the same for all dangers.
https://imgur.com/FFYx0b3
How a scene is created.
https://imgur.com/mPUDRLe
When the projectile is created by the boss.
https://imgur.com/YUlpXkl
When the projectile is created by the player.

« Last Edit: June 06, 2019, 02:19:32 pm by Edge123 »

colburt187

  • *
  • Posts: 2369
I see you pause the game when the player is killed, why do you do that and when do you un pause the game?

Edge123

  • Posts: 42
I use the pause block to stop any enemies moving around in the level and/or projectiles. I assumed that when you restart, the game automatically un pauses. Could that be the cause of the problem?

colburt187

  • *
  • Posts: 2369
Yeah thats your issue, the game is still in a paused state when a reloads. Put an Unpause block in the when created event at the start of the scene

Edge123

  • Posts: 42
So adding the un pause block at the beginning of a scene worked with the projectiles, but I'm still having problems with the music not starting up.  Any ideas?

colburt187

  • *
  • Posts: 2369
Try putting the loop music block in a do after 0.1 seconds block. So the game un pauses, then 0.1 seconds later the music loops.

Edge123

  • Posts: 42
So I did the do after block but it didn't work. I did some testing around and apparently removing the death sound from the code works :-\. I don't want to remove the death sound from my game so how can I implement it without it interfering the music?

colburt187

  • *
  • Posts: 2369
Ah yes, because you are fading out the sound, but you are fading all sound. Why do you need to fade out the sound? One fix could be setting volume to 100 when the scene loads.

Edge123

  • Posts: 42
The reason I fade out the sound is to prevent overlapping of music when the level is created again, and also, it would still be able to play the death sound. I did set the volume to 100 for when the scene loads but it still doesn't work.

colburt187

  • *
  • Posts: 2369
ok try setting the death sound to its own chanel. Play death sound on channel 5, fade out sound on channel 5 etc, see if that stops it interfering with the music.

Edge123

  • Posts: 42
So I tried doing the channels but it didn't work out well. For some reason, I put the death sound after the whole code plays out of getting killed by dangers, and it only works sometimes. I noticed that if the player was moving before the player died to dangers the music wouldn't start, but if the player went into the danger without moving, the music would start up. I'm not sure if this is a bug in the engine, or somehow, the player is interfering with the music.

Edge123

  • Posts: 42
Actually, I played around a bit more with the channels and it seems to be working fine! It's a shame I have to do separate channels for each scene that contains music but at least it works.

colburt187

  • *
  • Posts: 2369
I think you are probably make things more complicated than they need to be, but the more you play with it all the more you learn.