• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by indra p · May 21, 2014 at 01:43 PM · errorprojectapply

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

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Sprawl · May 21, 2014 at 01:46 PM 0
Share

I suggest you post the part of the script you're having an issue with instead 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.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image indra p · May 21, 2014 at 02:56 PM 0
Share

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?

avatar image Landern · May 21, 2014 at 03:17 PM 0
Share

It follows the girl in the bikini on mine, 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.

avatar image indra p · May 21, 2014 at 04:44 PM 0
Share

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..

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

23 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

To "Apply" to the project by using a script? 1 Answer

"The associated script cannot be loaded" on every Script in every GameObject in the project. Corrupted Project. 10 Answers

Unity 2017.2.1.p2 will not load projects... 1 Answer

IndexOutOfRangeExeption: Array index is out of range 1 Answer

`Random' does not contain a definition for `Range'? 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges