B
B
beerg_wtf2016-06-21 20:09:30
Unity
beerg_wtf, 2016-06-21 20:09:30

There is a children's joint with a script, can you help?

Hello, there is a jamb with a script, but I can’t understand what’s the matter (Since I’m new to this business).
I ask for your help, preferably with an explanation of the error.
Error:
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)
And here is the script itself:

using UnityEngine;
using System.Collections.Generic;

public class PlayerScript : MonoBehaviour {

  //Изменение скорости перемещения героя
  public float playerSpeed = 2.0f;

  //Текущая скорость перемещения
  private float currentSpeed = 0.0f;

  //Создание переменных для кнопок
  public List<KeyCode> upButton;
  public List<KeyCode> downButton;
  public List<KeyCode> leftButton;
  public List<KeyCode> rightButton;

  //Сохранение последнего перемещения
  private Vector3 lastMovement = Vector3();
  
  // Start/Update - Названия функций
  void Update () {

  }
}

PS (For the same copied, I apologize)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Basmanov, 2016-06-22
@beerg_wtf

Instead
, it should be
Use an empty constructor for lastMovement is not necessary, Vector3 is a structure and the default value at initialization will be the same zero.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question