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.

why is unity saying this in the console im really confused

Discussion in 'Visual Scripting' started by EvilBob99, Jan 24, 2022.

  1. EvilBob99

    EvilBob99

    Joined:
    Dec 12, 2021
    Posts:
    83
    so im making a small co-op game as a break from my main project and im a weird error that makes no sense

    here's my code for reference

    Code (CSharp):
    1.    private Rigidbody2D rb;
    2.     public Animator anim;
    3.  
    4.     public float movespeed;
    5.     public float jumpforce;
    6.  
    7.     public KeyCode jump;
    8.     public KeyCode right;
    9.     public KeyCode left;
    10.     public KeyCode shoot;
    11.  
    12.     public Transform groundcheckpoint;
    13.  
    14.     public bool isgrounded;
    15.     public float groundcheckradius;
    16.     public LayerMask whatisjumpable;
    17.  
    18.     // Start is called before the first frame update
    19.     private void Start()
    20.     {
    21.         rb = GetComponent<Rigidbody2D>();
    22.         anim = GetComponent<Animator>();
    23.     }
    24.  
    25.     // Update is called once per frame
    26.     private void Update()
    27.     {
    28.         isgrounded = Physics2D.OverlapCircle(groundcheckpoint.position, groundcheckradius, whatisjumpable);
    29.  
    30.         if (Input.GetKey(left))
    31.         {
    32.             rb.velocity = new Vector2(-movespeed, rb.velocity.y);
    33.         }else if (Input.GetKey(right))
    34.         {
    35.             rb.velocity = new Vector2(movespeed, rb.velocity.y);
    36.         }
    37.         else
    38.         {
    39.             rb.velocity = new Vector2(0, rb.velocity.y);
    40.         }
    41.  
    42.         if (Input.GetKeyDown(jump) && isgrounded)
    43.         {
    44.             isgrounded = false;
    45.             rb.velocity = new Vector2(rb.velocity.x, jumpforce);
    46.         }
    47.  
    48.  
    49.         anim.SetFloat("speed", rb.velocity.x);
    50.         anim.SetBool("grounded", isgrounded);
    and then the error is this

    NullReferenceException: Object reference not set to an instance of an object
    UnityEditor.Graphs.Edge.WakeUp () (at /Users/bokken/buildslave/unity/build/Editor/Graphs/UnityEditor.Graphs/Edge.cs:114)
    UnityEditor.Graphs.Graph.DoWakeUpEdges (System.Collections.Generic.List`1[T] inEdges, System.Collections.Generic.List`1[T] ok, System.Collections.Generic.List`1[T] error, System.Boolean inEdgesUsedToBeValid) (at /Users/bokken/buildslave/unity/build/Editor/Graphs/UnityEditor.Graphs/Graph.cs:387)
    UnityEditor.Graphs.Graph.WakeUpEdges (System.Boolean clearSlotEdges) (at /Users/bokken/buildslave/unity/build/Editor/Graphs/UnityEditor.Graphs/Graph.cs:286)
    UnityEditor.Graphs.Graph.WakeUp (System.Boolean force) (at /Users/bokken/buildslave/unity/build/Editor/Graphs/UnityEditor.Graphs/Graph.cs:272)
    UnityEditor.Graphs.Graph.WakeUp () (at /Users/bokken/buildslave/unity/build/Editor/Graphs/UnityEditor.Graphs/Graph.cs:250)
    UnityEditor.Graphs.Graph.OnEnable () (at /Users/bokken/buildslave/unity/build/Editor/Graphs/UnityEditor.Graphs/Graph.cs:245)

    what the actual hell does this error mean thank you for reading
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    3,517
    It's a bog-standard Null reference error, but the error doesn't look to actually be at all related to the script you posted, but something to do with a UnityEditor.Graphs script.
     
  3. BennyTan

    BennyTan

    Joined:
    Jan 23, 2014
    Posts:
    139
    stupid question, but have all your public variables been assigned something?
     
  4. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    12,407
    That doesn't happen in your code, and looks like Graph editor glitched out.

    Does this persist if you restart the editor?
     
  5. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    9,095
    What happens if you clear the log?
     
  6. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    8,909
    This isn't a post for the general discussion forum, it's a post for the scripting or visual scripting forums.

    I'll move it to the visual scripting forum for now.
     
    EvilBob99 likes this.
  7. EvilBob99

    EvilBob99

    Joined:
    Dec 12, 2021
    Posts:
    83
    ok thanks melvmay
     
  8. EvilBob99

    EvilBob99

    Joined:
    Dec 12, 2021
    Posts:
    83
    im going to try and restart it
     
  9. EvilBob99

    EvilBob99

    Joined:
    Dec 12, 2021
    Posts:
    83
    yeah unity had just decided it didn't like
     
    MelvMay likes this.
  10. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    8,909
    Yes, could well have been some bug in Visual Scripting here.