PlayClipAtPoint() causes a NullReferenceException error

First I have tried out your code as follow:

But my blocks will not be destroyed and I receive an error:

When I try it with the following code, it works fine:

What is wrong with this solution, because the sound is so loud as the others … ?

Hi Norbert,

With the 3D sound settings, the further the audio source is from the audio listener (typically attached to the camera) the quieter the sound will appear. Your collisions may be occurring nearer to the camera at the moment which may be why you cannot notice any difference.

The error message you are receiving is most likely because you do not have a camera in your scene which is tagged MainCamera. The static method main will return null if this is the case, hence your error.

Hope this helps :slight_smile:

See also;


Hello Rob

Thank you very much for your explanation and your solution (Tag “MainCamera”)!
It works now very fine.



You’re very welcome :slight_smile:

Privacy & Terms