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
0
Question by JSeeberg · Jun 02, 2013 at 01:17 PM · errordooropening

Need Help | Door Opening Script Error

Hallo,

I'm new to unity, and this morning I tried to make a door opening by a user input. And I got an error, hope someone can help me out.

This is the error:

UnassignedReferenceException: The variable Door of 'DoorLogic' has not been assigned. You probably need to assign the Door variable of the DoorLogic script in the inspector. DoorLogic+$changeDoorState$1+$.MoveNext () (at Assets/DoorLogic.js:43) UnityEngine.MonoBehaviour:StartCoroutine_Auto(IEnumerator) DoorLogic:Update() (at Assets/DoorLogic.js:11)

Here is the code I use:

 #pragma strict
 
 var Door: Transform;
 private var drawGUI = false;
 private var doorIsClosed = true;
 
 function Update () 
 {
     if (drawGUI == true && Input.GetKeyDown(KeyCode.E))
     { 
         changeDoorState();
     }
 }
 
 function OnTriggerEnter (theCollider : Collider)
 {
     if (theCollider.tag == "Player")
     {
         drawGUI = true;
     }
 }
 
 function OnTriggerExit (theCollider : Collider)
 {
     if (theCollider.tag == "Player")
     {
         drawGUI = false;
     }
 }
 
 function OnGUI ()
 {
     if (drawGUI == true)
     {
         GUI.Box (Rect (Screen.width*0.5-51, 200, 102, 22), "Press E to open");
     }
 }
 
 function changeDoorState ()
 {
     if (doorIsClosed == true)
     {
         Door.animation.CrossFade("Open");
         //Door.audio.PlayOneShot();
         doorIsClosed = false;
         yield WaitForSeconds(3);
         Door.animation.CrossFade("Close");
         //Door.audio.Play();
         doorIsClosed = true;
     }
 }

Thanks for looking into my problem, looking forward to solve it :)

Comment
Add comment · Show 4
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 ExTheSea · Jun 02, 2013 at 02:04 PM 0
Share

Did you assign the Door variable in the Editor?

avatar image JSeeberg · Jun 02, 2013 at 08:12 PM 0
Share

Thank you for your answer, I'm not quite sure on how I assign the Door variable in the Editor... may you help me out with that? :)

Thank you for answering :)

avatar image JSeeberg · Jun 03, 2013 at 10:28 AM 0
Share

Thank you ExTheSea, error solved! :-)

avatar image ExTheSea · Jun 03, 2013 at 03:55 PM 0
Share

I converted your answer to a comment and i will convert one of my comment to an answer so that you can accept it to mark the question as solved.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by ExTheSea · Jun 02, 2013 at 08:18 PM

If the script is actually attache to the Door then you can replace

 Door.

with

 transform.

If that's not the case: If you attach a script all the variables show up in the inspector below the name. then you just drag the gameobject on the Door variable.

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

15 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

Related Questions

Multiple Cars not working 1 Answer

Error line 22! Help. i dont know why? 1 Answer

3 errors in scrip. 1 Answer

what is wrong with this online FPS script(not done) ? 1 Answer

Expecting ':' Found '=' Error 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