Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Question why do i have this error

Discussion in 'Scripting' started by minhmvc, Jan 26, 2023.

  1. minhmvc

    minhmvc

    Joined:
    Jan 20, 2023
    Posts:
    3
    NullReferenceException: Object reference not set to an instance of an object
    UnityEditor.PropertyHandler.IsArrayReorderable (UnityEditor.SerializedProperty property) (at <11d97693183d4a6bb35c29ae7882c66b>:0)
    UnityEditor.PropertyHandler.UseReorderabelListControl (UnityEditor.SerializedProperty property) (at <11d97693183d4a6bb35c29ae7882c66b>:0)
    UnityEditor.PropertyHandler.GetHeight (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren) (at
     
  2. minhmvc

    minhmvc

    Joined:
    Jan 20, 2023
    Posts:
    3
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class jump : MonoBehaviour
    {
    public float height;

    bool grounded;

    Rigidbody2D myBody;
    Animator myAnim;

    // Start is called before the first frame update
    void Start()
    {
    myBody = GetComponent<Rigidbody2D>();
    myAnim = GetComponent<Animator>();
    }

    // Update is called once per frame
    void FixedUpdate()
    {
    if (Input.GetKey(KeyCode.UpArrow))
    {
    if (grounded)
    {
    grounded = false;
    myBody.velocity = new Vector2(myBody.velocity.x, height);
    }
    }
    }

    void OnCollisionEnter2D(Collision2D other)
    {
    if(other.gameObject.tag == "ground")
    {
    grounded = true;
    }
    }
    }
     
  3. minhmvc

    minhmvc

    Joined:
    Jan 20, 2023
    Posts:
    3
    this is my script
     
  4. AngryProgrammer

    AngryProgrammer

    Joined:
    Jun 4, 2019
    Posts:
    437
    From Nerdish to English: component don't exist so I can't use it. Check if you have Rigidbody2D on same game object like script.