Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
5
Question by Party Boy · Mar 11, 2014 at 11:50 PM · rigidbodylightingruntimeexceptionunassigned

Unassigned Reference Exception error?

Hey. So I have managed to shoot a light from a wand in my game, it works okayish for now, however in the console I keep getting this error:

 UnassignedReferenceException: The variable projectile of 'Light_Spell' has not been assigned.
 You probably need to assign the projectile variable of the Light_Spell script in the inspector.
 UnityEngine.Object.Internal_InstantiateSingle (UnityEngine.Object data, Vector3 pos, Quaternion rot)

And the line of code the error points to is this:

 Rigidbody instantiateProjectile = Instantiate(projectile, transform.position, transform.rotation) as Rigidbody;

How can I solve this? Its probably some dumb error but I'm new to Unity so not sure what it could be.

Comment
Add comment · Show 2
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 Feyyyyy · Nov 30, 2016 at 02:08 PM 0
Share

You should not approach errors like they are dumb, unless you are %100 sure that you know the cause and it is really dumb. All errors must be fixed in sight :).

avatar image Feyyyyy · Nov 30, 2016 at 02:26 PM 0
Share

This error causes because projectile property of Light_Spell script is null. How do you assigning projectile property of Light_Spell?

4 Replies

· Add your reply
  • Sort: 
avatar image
27

Answer by grebenyuksv · Jan 12, 2015 at 04:45 PM

When I had the same error, the reason was that I had accidentally dragged the script to a wrong object in the scene view, after which I had attached the script to the correct object. Sounds like a joke, but nontheless, check if your script is attached to any unwanted object.

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 Ziaxp · Nov 30, 2016 at 01:37 PM 0
Share

had the same prob. but yes, mistakenly assigned the script to the wrong object. thanks it worked. +1

avatar image unity_1gbftw · May 04, 2018 at 11:26 PM 0
Share

Is there any quick way to check this or do I have to go through each individual one?

avatar image Ayrnas · May 09, 2019 at 03:04 AM 0
Share

This was it for me. Except it wasn't an accident, I just thought that unchecking the script on the other object would mean that it no longer affects anything. Apparently not.

avatar image
3

Answer by Gooey-Man · Mar 12, 2014 at 12:11 AM

Did you assign the variable to the script its self or the object that the script is on? If you assigned it to the script assign it to the object the script is on instead.

Comment
Add comment · Show 1 · 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 Party Boy · Mar 12, 2014 at 12:18 AM 0
Share

I have a WandLight that has the LightSpell script attached to it and that has the Light_Shot prefab put into it. I just dragged and dropped the prefab onto it

avatar image
1

Answer by wpatel · Feb 26, 2020 at 08:57 PM

In the event someone ventures here in 2020, I've seen this error occur on not one but tens of prefabs (if not all) due to a Unity version upgrade.
Opening and resaving the prefab is one way to resolve it.
Deleting your Library folder was the way we solved it.
Unity regenerates the folder and everything worked.

Why this occurred for the project I was working on?
The project was stored on a git repo.
One user upgraded the project to Unity 2019 (from 2018) and committed those changes.
A user who pulled down those changes and opened up the project in 2019.
No migration was needed so Unity didn't do any "cleanup" to project files.
Hit Play. Lots of Unassigned Reference Exceptions.

Don't know the dirty details of what happened but fortunately the prefab files themselves were not corrupted.

Comment
Add comment · Show 1 · 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 euming_lee · Dec 10, 2020 at 07:32 PM 0
Share

Deleting the Library\ folder did not work for me.

In my $$anonymous$$onoBehaviour, I have a public List of GameObjects that is uninitialized (null).

 public List<GameObject> people;

I Initialize it in both Awake() and Start() as follows:

     if (null == people) {
         people = new List<GameObject>();
     }

I will get an error like this: UnassignedReferenceException: The variable people of Room has not been assigned. You probably need to assign the people variable of the Room script in the inspector.

This was a prefab that used to work in earlier versions of Unity3D. So, maybe List needs to be assigned in the inspector rather than created on the fly in the script now?

I will try some experiments and maybe report back later if I remember.

avatar image
0

Answer by Ranger-Ori · Oct 06, 2021 at 02:08 PM

grebenyuksv said, that he didn't notice since he accidentaly dragged the script to the wrong object.
It can be easily fixed if you press on FindAllReferencesInScene for a certain script (right click on script).

I had a much dumber issue.
I accidentaly dragged the script to the correct object, twice. (facepalm)

It was hidden within other components in the inspector, and FindReferences pointed me to only one gameobject.

Comment
Add comment · 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

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.

Follow this Question

Answers Answers and Comments

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

Advanced runtime lighting calculation 0 Answers

How to refresh rigidbody colliders modified at runtime 0 Answers

Connect two rigidbody gameobjects together at runtime? 0 Answers

Change screen orientation in runtime 0 Answers

UnassignedReferenceException 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges