RandomBool.cs 558 B

1234567891011121314151617181920212223
  1. using UnityEngine;
  2. namespace BehaviorDesigner.Runtime.Tasks.Unity.Math
  3. {
  4. [TaskCategory("Unity/Math")]
  5. [TaskDescription("Sets a random bool value")]
  6. public class RandomBool : Action
  7. {
  8. [Tooltip("The variable to store the result")]
  9. public SharedBool storeResult;
  10. public override TaskStatus OnUpdate()
  11. {
  12. storeResult.Value = Random.value < 0.5f;
  13. return TaskStatus.Success;
  14. }
  15. public override void OnReset()
  16. {
  17. storeResult.Value = false;
  18. }
  19. }
  20. }