TriggerEnter race condition?

Forums 💬 NodeCanvas ⚙️ Support TriggerEnter race condition?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #16349
    mrwetsnow
    Participant

      Hi,

      I have a simple tree like:

      Sequence (Dynamic)
      If TriggerEnter:  Save object as variable, then use variable in children.
      If CanSeeTarget: Seek Target.

      There is a character that wonders around collecting objects.  When it touches one of the objects, the TriggerEnter path executes and works properly.  In the normal case.  Occasionally, when two objects that are being collected are right next to each other, I think the following race conditions happens.

      TriggerEnter called for first object.  Object variable is updates to use later (I am using dynamic variables here).

      Before the child of TriggerEnter is called, the second collision happens, and TriggerEnter is called again.  It updates the object variable to the new one that was just collided with.  And now the original object is not processed anymore.

      If I remove the TriggerEnter part of the tree, and just do it manually in code:

          private void OnTriggerEnter(Collider other)

      {

      if (other.CompareTag(LevelManager.Instance.CollectibleTag))

      {

      Collect(other.gameObject);

      }

      }

      Everything works as required, since there is no intermediate variable to get overwritten.

      I’d like to handle this inside the BehaviorTree.  I suppose I can create my own Action that both catches the Trigger and executes the Trigger code all at once.  But I am wondering if I am simply using this wrong and there is a way to do this with the built in methods.

      Thank you

      Dan

      #16352
      Gavalakis
      Keymaster

        Hello again,

        Although I am not able to reproduce this yet, I can confirm that this can be possible since Unity trigger calls are made on a separate thread than normal Update (through which graphs are updated normally). Can you please confirm that in Unitys Script Execution Order editor, the script named “ParadoxNotion.Services.MonoManager” is at a positive time (anything after “Default Time”) ?
        I may need to reimplement how trigger/collision/etc conditions work. Thank you for pointing this out!

        #16351
        mrwetsnow
        Participant

          It’s set to 100. This is what it looks like (see attached file).

           

           

          #16350
          Gavalakis
          Keymaster

            Hello again,
            Yes, that is correct. I will need to dig into this a bit more and see if there is any potential solution for that. It’s tricky since trigger/collisions events happen totally async than the graph update, but hopefully there is a solution 🙂
            Thank you.

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