Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question [Open Project] Help in Understanding Transitioning Logic between states (TransitionalTable)

Discussion in 'Open Projects' started by punkrooks, Nov 11, 2021.

  1. punkrooks

    punkrooks

    Joined:
    Apr 15, 2016
    Posts:
    34
    So I begin looking at the repo and was going through the code and I am getting some hard time to get along with the flow as most of the things were new for me and I am still learning btw.
    Currently I was not able to wrap my head around the logic written where it checks if a state should transition to another state.

    https://github.com/UnityTechnologie...ipts/StateMachine/Core/StateTransition.cs#L47

    https://github.com/UnityTechnologie...ne/ScriptableObjects/TransitionTableSO.cs#L50

    I really apologize if this question is too much of a beginner. Feel free to close it if so.

    For eg: we have
    Idle => [ Some conditions ] => Fight


    upload_2021-11-11_10-9-0.png
    (please ignore the actual condition added, it is just for testing.. )

    with this, i am visualizing
    for example :
    upload_2021-11-11_10-11-16.png

    Q1 So now, Is it equivalent to
    Option 1 or Option 2 ?:

    upload_2021-11-11_10-12-53.png

    I am understanding as Option 1, please correct me if I am wrong.

    And the main part where I am having trouble is the transitioning logic
    The Operator are first taken
    and from there result groups are generated
    And used for furthur transitions.

    upload_2021-11-11_10-19-5.png

    How are this ResultGroups used for transition accordingly. If someone could explain even in some few lines or give some reference, waypoint, anything. That would be really helpfull. I did look up the code, but I am still having some gaps.

    Thanks
     
  2. punkrooks

    punkrooks

    Joined:
    Apr 15, 2016
    Posts:
    34
    Understood

    if condition is equivalent to Option 1

    and transitions are done accordingly, for eg
    there are 5 conditions and there are inbetween operators as follows:

    Code (CSharp):
    1. c1 || c2 || ( c3 && c4 && c5 )
    then this will get into result group as

    1 1 3

    1 is for OR
    where 3 is the total adjacent AND present

    furthur they are converted to condition checked array say

    T T F

    Then it will return T, as first condition itself returned true

    if it was F F F, it be returned False and no transition will be performed