Problem with multiple audio clips

hi i keep getting an error message but cant find the solution
pls help (issue with multiple audio clips only my thrust audio works collision and finish audio doesnt)

Hi Ibrahim,

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.


See also:

Hi I checked the one line of code that had the error it is exactly the same as ricks also I have attached all the audio files to successfully and crash the error only comes when I hit an obstacle or the finish pad
I tried fixing it but it won’t work
Could you pls send me the complete correct code for the csharp script CollisionHandler thx

The code is probably not the problem. Variables are like boxes.

A real life analogy: If you order something on the internet but get an empty box, the box could be fine, the deliverer could be truthworthy but that doesn’t change the fact that somebody forgot(?) to put the item into the box. The problem is: Where is your item?

The same applies to your project: Where is the missing object?

If you suspect that there might be a problem in your code, have you already compared your code to the Lecture Project Changes which can be found in the Resources of this lecture?

Where did you assign the references (= links to objects)? If you did that in your prefab but not in the game object in the scene, the game will throw a NullReferenceException at runtime because the game uses the game object in the Hierarchy.

If that didn’t help you find and solve the problem, have you already rewatched the video at least one more time? Maybe a detail is missing in your project.

I still can’t find a solution or were the problem is
I’m not sure what’s wrong

Can you show the full error? Open the console tab, click on the error and screenshot the console. The error will say something like

NullReferenceException: Object reference not set to an instance of an object
Rocket.StartDeathSequence () (at Assets/Rocket.cs:86)
... more lines...

Go to that line. As @Nina mentioned, you can double-click the error and it will take you there. In this example it’s the Rocket.cs script. Share the code it takes you to.
Find the object in the hierarchy that uses this script. Share a screenshot of the inspector for that object

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

Privacy & Terms