unity3d - Getting error saying MissingReferenceException in unity 5 c# -


in unity car game project, have four car(one player car) respective four indicators (one main indicator). indicator moves vertically upward on update function , each indicator move random speed. in case of car, player car not move upward , downward, moves left , right user. other car not move left,right,forward,backward. rather other car shows forward , backward move animation difference between indicators(there 4 indicator, indicators means 3 indicator references 3 cars other player car) , main indicator position(main indicator reference player car).

i have 2 scene, 1 user interface( contain play button,exit button etc.). , scene game play.

when click on play game button goes game scene , racing game start no error. after completion of game, user interface scene loads automatically saying "replay game", "exit game". in case if click on "replay game" button, game scene opens , indicator start move car not move( not show animation) respect movement of indicator. , error occur here saying

missing reference exception: object of type movecar(it script attached car object) has been destroyed still trying access it.your script should either check if null or should not destroy object.

during error, check game object car , contains movecar script there still same error. script working fine on first step did not have attach code here. appreciated. getting stop in problem many days.

before loading scene on replay button add line of code dontdestroyonload(playercarobjecthere);


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -