Audio and ParticleSystems not working when the game is run

So far I’ve been taking everything in the lecture step by step to make sure I do not make any mistakes as I am completely new. During the last lecture involving multiple pieces of sound I followed step by step instructions and still was unable to get the sound to work. In my frustration I moved on to this lecture. Same case happens. When applying more than one particle effect they never animate. So I went back to the script and opened up Rick’s code from the resources provided and examined every single line to make sure I didn’t get anything wrong. Could it be unity’s fault that it does not animate or make any sound?!

Hello Mohammed,

It can be frustrating when you run into difficulties like this and can’t quite see what is going wrong. It is unlikely to be because of Unity however.

If you would like a second pair of eyes to look at things, zip up your project files (all of them) and share them with me and I will take a look. The forum will allow uploads of 10mb, so if your .zip file is larger than that, please use a service such as Google Drive or Dropbox and provide me with the URL.

Let’s see if we can get you moving forward again :slight_smile:

3_Project_Boost.zip (3.4 MB)

Thank you so much for willing to look into it!

Going to have a look now Mohammed - I will update this post with anything I find :slight_smile:


Updated Wed May 02 2018 10:28

Hi Mohammed,

Ok, I have taken a look and outline the issues and resolutions below.


Audio

The audio issue is due to the AudioSource component on your Rocket. Not only is it disabled (no tick in the tick box within the Inspector);

image

…but it’s settings aren’t quite right.

image

The pitch is set to -1.91 - I don’t think humans can hear at that range, possibly dogs, not sure, but when you’re testing if you hear a lot of barking outside you’ll know :slight_smile:

If you enable the AudioSource and set the pitch to 1, at least to start with, the audio starts working again, and for all of the events, thrusters, crashing and successful landing.

It looks like you may have experimented with the other settings also, these don’t appear to be having a negative effect, but if I were you I would just remove the existing AudioSource component from your rocket prefab and add a new one. That would resolve all of the audio issues in one go.

image

It doesn’t really matter at the moment that Play On Awake is still ticked, as you don’t have an assigned AudioClip, thus it doesn’t have anything to play, but you could potentially untick this option also.

The Spatial Blend is also a little irrelevant for this game, whilst it is a 3D game you the AudioListener which is attached to the camera never really moves away from the AudioSource for the sound to drop off, thus the 2D option should be fine.


Particles

The thruster particles appear to be working correctly when I play the game.

The crash and successful landing particles do not currently appear. If I select them in the Hierarchy under the Rocket GameObject they appear within the scene as expected.

If you expand your Rocket in the Hierarchy and then select your Rocket, within the Inspector you’ll see the three properties on it for the three particle systems. In the Inspector, select the Rocket Jet Particles, you’ll note that the corresponding GameObject in the Hierarchy gets highlighted in yellow.

image

If you now repeat that for the Explosion and Success particles you will note that it instead highlights the prefabs for those ParticleSystems within Assets.

image

To resolve this, drag the Explosion Particles GameObject from the Hierarchy to the Explosion Particles property on your Rocket within the Inspector. Now repeat this process for the Success Particles.


Two other minor issues I have spotted which you may want to fix.

  • the transform for your Success Particles wasn’t reset, as such, when you land on the landing pad the particle effect appears way off to the right. If you reset the transform’s position (not rotation) for this it will then appear from the Rocket when you land successfully, but obviously from the rocket’s transform, so if you then set the Y component to -2 (for the success particles), they will appear from the bottom of the rocket.

  • in your second scene your rocket starts above a platform, it falls to the floor immediately and creates a success scenario, this repeats over and over. You can resolve this by either changing the tags on the two pads around the other way (assuming you want the player to fly from right to left this time), or move the rocket back to the launch pad instead of the landing pad.

NOTE: Don’t forget to either make the changes to your prefabs, or, apply the changes to your prefabs by clicking the Apply button in the Inspector for those you change.

image


I hope all of the above helps :slight_smile:

Thanks, Rob you are the best! Very clear and easily understandable explanation! I’m kinda face palming myself because I was playing with the audio source check box but not the pitch or other properties :smile: Also thank you for pointing out why my particle effects do not work. If you don’t mind can you explain why there is such a difference? I think I just dragged from the asset box straight into the Rocket properties. I think Ben alluded to it a few times about why during the lecture but I didn’t understand at the time. With this I feel so relieved. I wish you a pleasant day!

1 Like

Hi Mohammed,

You’re very welcome :slight_smile:

If you don’t mind can you explain why there is such a difference?

The ParticleSystems were not being instantiated. When they are attached to a GameObject Unity instantiates objects/components.

You can reference a prefab, in the same way you had those two which weren’t working, however you would then need to instantiate a new instance of it at runtime with code.

Hope you have a great day too :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms