unity3d - Sound doesnt play when object collides with collider/ How to play sound and change scene at the same time - unity -


hello want sound play when gameobject collides collider. checked unity documentation , don't seem understand why not working. have audiosource applied collider.

enter code here public audioclip impact;     audiosource audiosource;     void start(){         audiosource = getcomponent<audiosource>();      }     void oncollisionenter2d(collision2d coll){         if (coll.gameobject.tag == "enemy") {             audiosource.playoneshot (impact);             application.loadlevel ("win");         }     }     } 

the problem in start function because 's'of start capital

replace this

void start()

with

void start()

this fix null reference exception


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -