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.
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.
It worked in the video, which demonstrated how to use the scripts. $$anonymous$$ost 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.