- Home /
NullReferenceException: Object reference not set to an instance of an object BotControlScript.Start () (at Assets/script/BotControlScript.cs:41)
i douwnloaded a sample project somewhere and used the script to my own project everything seem fine but i got this error message :
NullReferenceException: Object reference not set to an instance of an object BotControlScript.Start () (at Assets/script/BotControlScript.cs:41)
and also after i build it ,the camera is not working. it not following the player as how its work in the preview...
here is my project file : https://www.dropbox.com/s/oanyfvnpgw1lj4q/gumbla.rar the scene located in "asset" folder
could someone find a way how to fix it?
thank you
I suggest you post the part of the script you're having an issue with ins$$anonymous$$d of the whole script. It's quite painful to naviguate through a whole code while the issue it probably just a not initiated variable.
Your camera is probably not working because of the error too.
Also, be sure that if the script you downloaded needed you to assign a gameObject in editor, you didnt forget to do it.
Answer by Landern · May 21, 2014 at 01:47 PM
In the script BotControlScript.cs, line 41, you're trying to get a reference to a transform that belongs to an gameobject named "Enemy". Your scene does not contain such an object, so it can't find the GameObject and of course because it can't find that, the property transform doesn't exist... hence the null reference exception. Add an enemy, read up on GameObject.Find and fix your scripts expectations.
thanks.. i added an blank object then named it enemy..now the error messase is gone...but the camera still not working when i build the game...its not following the player..any solution?
It follows the girl in the bikini on $$anonymous$$e, this is from your project download, i have no idea why it wouldn't work for you unless you modified something and what was uploaded to dropbox differs.
Its weird..Did you build it?..I mean build to exe files..the camera work when I played it in unity.. But not after I run the exe..