Destroying GameObject from inside FSM

NodeCanvas Forums Support Destroying GameObject from inside FSM

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #9589

    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”.

    Attachments:
    You must be logged in to view attached files.
    #9593
    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!

    Join us on Discord: https://discord.gg/97q2Rjh

    #9592

    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?

    #9591
    Gavalakis
    Keymaster

    You are welcome and thanks 🙂

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

    Cheers!

    Join us on Discord: https://discord.gg/97q2Rjh

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