How to change global variables in BT?

vasepo

New member
i want to make BT like the following codes.

int count = 0; // global variable
int maxCount = 10; // global variable
while( count < maxCount ){
count = count + 1; // how to convert this code to BT task?
Debug.Log( count );
yield return new WaitForSeconds(1);
}


Repeater Task : count = 10
Wait Task : waitTime = 1

Screen Shot 2021-05-18 at 8.33.29 AM.png
 
my solution is to make custom action task.


public class CountAdd : Action
{
public SharedInt count;

public override TaskStatus OnUpdate()
{
count.Value += 1;
return base.OnUpdate();
}
}
 
Top