Search Unity

Question GameObject doesn't work, pls help

Discussion in 'Visual Scripting' started by usovichden, Apr 20, 2021.

  1. usovichden

    usovichden

    Joined:
    Apr 19, 2021
    Posts:
    4
    Hi guys, I'm very newbie and I don't know what to do with this problem. I make some Bolt scheme which goal is to choose some object on desk and return mouse coordinates, but when I try to run it I have next notification: "Invalid operation exception: Missing target object for 'UnityEngine.GameObject.gameObject'
    Pls help me, screenshots attached
     
  2. BeeBeeCue

    BeeBeeCue

    Joined:
    Feb 13, 2018
    Posts:
    3
    What gameObject do you have the flowGraph on?
    Does it have a rigidbody?
     
  3. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,076
    Looks like you're raycasting on mouse position every frame which means that when the ray does not hit anything, the GameObject is null. You need to introduce a "Null Check" node to work around this issue so when the ray does not hit an object, it stops the logic before it throws the error.