The FindWithTag task will error out if random is set to true and no game objects with that tag exist.
My proposed fix is to add a line checking for that:
Though not sure if that's the best solution.
My proposed fix is to add a line checking for that:
C#:
public override TaskStatus OnUpdate()
{
if (random.Value) {
var gameObjects = GameObject.FindGameObjectsWithTag(tag.Value);
if (gameObjects.Length == 0) return TaskStatus.Failure; // this line added
storeValue.Value = gameObjects[Random.Range(0, gameObjects.Length)];
} else {
storeValue.Value = GameObject.FindWithTag(tag.Value);
}
return storeValue.Value != null ? TaskStatus.Success : TaskStatus.Failure;
}
Though not sure if that's the best solution.