Suggested change to ConditionList.cs

NodeCanvas Forums General Discussion Suggested change to ConditionList.cs

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #9212
    etabubu
    Participant

    Hi!

    I’m proposing a small change to ConditionList.cs in order to return false as soon as a condition fails, in case of “ALL True” is selected.

    I changed the code myself and it works perfectly.
    At line #49 I added:

    This solves two problems:
    – If the next condition has a required field and it needs to check something on a variable that is set by a previous condition, it won’t throw an exception saying that the required field is not assigned when the previous condition fails
    – Improves performance because you don’t need to check all conditions in case one of them fails

    Take a look at the screenshot for an example.
    The condition “Coin Spawned” checks if a coin has spawned. If true, it will save the coin into a BB variable. The next condition needs to check if the coin is close enough, so it needs to access that BB variable. The problem is that if there’s no coin spawned the variable will be set to NONE and the Check Distance condition will throw an exception.

    Thank you!

    #9214
    Gavalakis
    Keymaster

    Yep,
    I agree and fixed it as well 🙂

    Thanks

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

    #9213
    etabubu
    Participant

    Brilliant!

    Thank you 🙂

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