Set active is not working

Forums 💬 NodeCanvas ⚙️ Support Set active is not working

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #15800
    moonbeam
    Participant

      I made a simple FSM graph where the patrolling agent will deactivate a target after seeing, and also logs ‘CanSee’ in the console.

      The target gets deactivate in the hierarchy but the the agent still logs  ‘CanSee’.

      I am using this method as destroy game object is causing null reference exception error

      [attachment file=”FSM1.PNG”]

      [attachment file=”FSM2.PNG”]

      #15801
      Gavalakis
      Keymaster

        Hello there,

        There is indeed an omission and the CanSeeTarget code does not check whether or not the target gameobject is deactivated or not. I have just fixed this for all CanSeeTarget versions and attached the files for you here.

        Regarding checking a gameobject reference that is later destroyed the best solution for that would be to use a Blackboard Variable for that particular gameobject and check to see if the Variable is null (with the “Blackboard/Check Null” Condition Task) before calling any action that uses that potentially destroyed gameobject. By that same approach, you “Destroy Gameobject” Action Task, will of course also have to use that Variable instead of a direct gameobject reference.

        Let me know if this works for you.
        Thank you.

      Viewing 2 posts - 1 through 2 (of 2 total)
      • You must be logged in to reply to this topic.