- Home /
Question by
smirlianos · Jun 05, 2016 at 04:37 PM ·
errorrigidbodymissingmissingreferenceexception
Unknown problem with MissingReferenceException
Ok, so my code is only this:
#pragma strict
var speed : float;
var rb : Rigidbody2D;
function Start () {
rb = GetComponent(Rigidbody2D);
}
function Update () {
rb.velocity.y = Input.GetAxis("Vertical") * speed;
}
My scene has only one sprite(with rigidbody2D) & the camera.
This is the error I get. What's going on?
MissingReferenceException: The object of type 'Object' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEditor.Editor.IsEnabled () (at C:/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:589)
UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1151)
UnityEditor.InspectorWindow.DrawEditors (UnityEditor.Editor[] editors) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1028)
UnityEditor.InspectorWindow.OnGUI () (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:352)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Comment
it shouldn't be rb.velocity.y = Input.GetAxis("Verrtical") * speed
I don't think. What is your code meant to do?
try to use C# that always works. If you want I can give you a c# script that works
Your answer
Follow this Question
Related Questions
Check For MissingReferenceException 1 Answer
Shadergraph looks for .hlsl file in wrong place. How do I change that? 1 Answer
[HELP!!] Files all missing while I update the version from Unity 2018.3.12f1 to Unity 2019.1.4f1 0 Answers
Destroyed Object Error 2 Answers
Error: NpRigidDynamic::isSleeping: Body must be in a scene. 1 Answer