MoveToGameObject.cs bug?

NodeCanvas Forums Support MoveToGameObject.cs bug?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #14933
    mrwetsnow
    Participant

    Hi,

    I am new to this, so I am not sure if this is a bug, or I am just holding it wrong.  I am using the “Seek (GameObject)” action.  There seems to be a race condition where if the target that is being navigated towards is destroyed.  The OnUpdate function then fails, as target is now null.

    This can be trivially fixed with the following line in the OnUpdate method, at the top:

    if (target.value == null) { EndAction(false); return;

    Do I understand this correctly?  I tried to put a Condition right above the Seek task that checks if the target is null, but that doesn’t help. My understanding is that the Check and the Action happen in different frames.  Is there a proper way to synchronize things like this, or is the cod change the correct way to go here?

    Thank you

    Dan

    #14948
    Gavalakis
    Keymaster

    Hello Dan and welcome.

    Your fix/solution is very correct for this case where the object is destroyed while the action is running.
    I will add this fix for the next version as well 🙂

    Thanks!

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

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