Destroying GameObject from inside FSM

Forums 💬 NodeCanvas ⚙️ Support Destroying GameObject from inside FSM

  • This topic has 0 replies, 2 voices, and was last updated 11 years ago by Gavalakis.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #19062
    noio
    Participant

      I’m trying to destroy the object that controls the FSM (in order to upgrade him to another unit type).

      Simple, in theory:

      FSM

      But I keep getting this error:

      I have also tried to put the “Destroy(gameObject)” call inside the method ( PromoteFromFSM() ), but the same thing happens.

      I used to have a workaround:

      But this extra frame of waiting time was causing _other_ trouble. I’d rather just destroy “right away”.

      #19065
      Gavalakis
      Keymaster

        Hello,

        Please add a null check for the currentState at line #72:

        The DestroyGameObject action is created to be called in the Update method of the action (instead of OnExecute) and exactly before the line of error, the current state Update is called, and thus the problem.

        I’ve tested with the null check now and works as expected, but let me know.

        Thanks!

        #19064
        noio
        Participant

          Thank you so much! You are unbelievably fast 😀

          By changing this, does that mean it’s possible to call Destroy(gameObject) from ‘generic’ ExecuteFunction actions too?

          #19063
          Gavalakis
          Keymaster

            You are welcome and thanks 🙂

            Yeah. I just tested this to confirm and works fine 🙂

            Cheers!

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