|
When I try to run my script I get this error: NullReferenceException Movementscript.FixedUpdate () (at Assets/Movementscript.js:7) Here is my script: I don't see any problem with the script, so can someone explain to me what's wrong?
(comments are locked)
|
|
This error means that some variable is empty, but at runtime the script is trying to use the thing that variable should be referencing to. It happens often when you forget to drag some object to an Inspector variable - like target in camera following scripts. Honestly, in your script the suspect #1 should be the Camera.main variable, but there are evidences of its innocence: the message error indicates line 7, and Camera.main is referenced in line 6 (at least in the fragment above), not to mention the fact that you surely would notice if there were no camera in the scene. In line 7, the only variable referenced is rigidbody, but when it's empty Unity usually shows a different error message: (Missing Component Exception: There's no 'Rigidbody'...). If the rigidbody has a Joint, its Connected Body variable must be defined, or you may get an error. All it's controlling is a ball that's supposed to roll. The ball is rigidbodied. The camera is attached, so i'm completely confused as to what is causing this error.
Jul 09 '11 at 02:03 PM
blackmethod
(comments are locked)
|
« previous 1 2

I tested this script and it gave "Missing Component Exception: There's no 'Rigidbody'... at line: 7". I had no rigidbody, of course, just to test the script. With a rigidbody added, no errors were flagged. Just a shoot in the dark: do you have a main camera?
Eh em. One of my helpers clearly came in and deleted the rigidbody... Sorry for uhm. Wasting time.
Even after I fixed the rigidbody I get the same error.