• Unity
  • Services
  • Made with Unity
  • Learn
  • 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
  • Forums
  • Answers
  • Feedback
  • Issue Tracker
  • Blog
  • Evangelists
  • User Groups

Navigation

  • Home
  • Unity
  • Industries
  • Made with Unity
  • Learn
  • Community
    • Forums
    • Answers
    • Feedback
    • Issue Tracker
    • Blog
    • Evangelists
    • User Groups
  • Get Unity
  • Asset Store

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 /
  • Help Room /
avatar image
0
Question by The-Goliath · Jan 22, 2016 at 06:35 PM · c#mousedoordraggable

Draggable Door Problems

Hello all,

I've recently come across a tutorial on YouTube (here) showing how to have draggable doors like Amnesia, with the 2 scripts included in the description. I applied and set them up just how the video demonstrates, but I'm only getting errors.

First, I get an error when I click (and hold) the mouse button and I'm not even near the door (the error is continuous and builds up as long as I hold down the mouse button):

 NullReferenceException: Object reference not set to an instance of an object
 DragRigidbodyUse.Use () (at Assets/DragRigidbodyUse.cs:177)
 DragRigidbodyUse.FixedUpdate () (at Assets/DragRigidbodyUse.cs:92)


Then, I get a 2nd error when I approach the door and click the mouse, which is also continuous as long as I hold the mouse button down:

 NullReferenceException: Object reference not set to an instance of an object
 DragRigidbodyUse.holdObject () (at Assets/DragRigidbodyUse.cs:149)
 DragRigidbodyUse.FixedUpdate () (at Assets/DragRigidbodyUse.cs:76)


Finally, while I'm at the door, I get a single error every time I release the mouse button:

 NullReferenceException: Object reference not set to an instance of an object
 DragRigidbodyUse.DropObject () (at Assets/DragRigidbodyUse.cs:163)
 DragRigidbodyUse.FixedUpdate () (at Assets/DragRigidbodyUse.cs:79)


I know very little C#, and have tried to understand what's going on, and even asked the original creator of the script for help, but so far, no luck. All of the errors point to the "DragRigidbodyUse" script.

Could someone please help me understand what's going on here? I'm at a loss.

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 ShadyProductions · Jan 22, 2016 at 07:56 PM 0
Share

A null reference on an object means that the thing you are trying to access or read, doesn't have exist.

I don't really suggest you just use scripts like this if you have very little experience with it. It is difficult to explain and try to fix your problems when it is just copy and paste code that might not even work efficiently or not even work at all.

avatar image The-Goliath ShadyProductions · Jan 24, 2016 at 05:10 AM 0
Share

It worked in the video, which demonstrated how to use the scripts. Most of the comments were satisfied, and well, I've tried just about everything else I've been able to find for draggable doors, and nothing has really worked. Normally I try to really understand what's going on in any third-party scripts I implement, but with these stretching beyond the small bit of C# I understand, I tried and simply couldn't wrap my brain around it. Truthfully, I'm a little desperate here.

EDIT: I know what NullReferenceExceptions are. I just kept running into a wall when trying to figure out what was missing.

0 Replies

· Add your reply
  • Sort: 

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

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

how to make a objesc follow the mouse in the 3d world,how to make a object follow the mouse on the 3d world 0 Answers

Checking rotation of door 0 Answers

Need help with this code? thanks. 2 Answers

Click Button and Follow Mouse 1 Answer

HOW TO MOVE A OBJECT TO ANOTHER OBJECT SMOOTHLY NOT INSTANTLY? 0 Answers

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