Hi,
I am using unity 2018.2.6 for this project.
I made the changes as mentioned in the lecture but the sound is not playing. I am getting the below error in console.
" NullReferenceException: Object reference not set to an instance of an object
EnemyDamage.KillEnemy () (at Assets/Scripts/EnemyDamage.cs:42)
EnemyDamage.OnParticleCollision (UnityEngine.GameObject other) (at Assets/Scripts/EnemyDamage.cs:26) "
NullReferenceException means that a reference (“link”) to an instance is missing. Double click on the error message to see to which line in your code it is referring. If you exposed a field in the Inspector, make sure that it’s not empty.
As you can see in the video clip link I have shared already, all the exposed fields in EnemyDamage script on Enemy prefab are filled.
But still the error is coming.
Also, the line for which error is shown is the PlayClipAtPoint line I have mentioned before. If in that line I replace “Camera.main.transform.position” with just “transform.position”, I don’t get any errors.
But as per the lecture, to fix the audio issue, we need it to be “Camera.main.transform.position”.
So, why using “Camera.main.transform.position” is causing this error?