Hello, I have a question about sequence.

OhJeongSeok

New member
Hello, I have a question about sequence.

Sequence1.png

I have a behavior tree like this.

Conditional Compare Shared bool is a conditional.
This compares two boolean variables.
Returns true if they are equal, false if they are different

Zombie Attack Action is triggered if the boolean variable is true.
This continues until the end of the zombie hit animation.

I have a problem.
I want to keep track of changes in variables.
So I set the abort type of sequence to both.
If compare shared Bool returns false, the zombie attack action ends in the middle of the animation.
Although the state of the action persists.

Sequence2.png
In this state, the Zombie Attack Action is terminated if Compare shared bool returns false.

How do I solve this problem.
help me please.
Thank you for reading.
 
Last edited:

Justin

Administrator
Staff member
Instead of setting the abort type to both try just setting it to lower priority - this will prevent the bool from aborting the animation.
 

OhJeongSeok

New member
Instead of setting the abort type to both try just setting it to lower priority - this will prevent the bool from aborting the animation.
Thanks Justin.
I solve this problem. But I have another problem.
Sequence1.jpg

At the end of the Zombie Attack Action, the Behavior tree is closed.
I want Compare shared bool to be checked over and over again.
 

OhJeongSeok

New member
C#:
public bool DoAttack = false;
public bool InAttack = false;

public void AttackProcess()
{
    if(DoAttack)
    {
        if(InAttack == false)
        {
            StartCoroutine(PlayAttackAnimation());
        }
    }
}

IEnumerator AttackCoroutine()
{
    // InAttack set true to prevent call AttackCoroutine()
    InAttack = true;

    //Start Attack animation
     animator.Play("AttackAnimation", 0, 0.0f);

    while(animator.GetCurrentAnimatorStateInfo(0).normalizedTime < 0.9f)
    {
        yield return null;
    }

    // return Idle Animation
    animator.Play("IdleAnimation", 0, 0.0f);

    InAttack = false;

}
I want to make behavior tree like above code.
I want to check change of the DoAttack variable.
and abort animation when attack animation play
 

Justin

Administrator
Staff member
You should have a task that is always active, such as the idle task in this video:

 
Top