You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
620 B
C#
27 lines
620 B
C#
using UnityEngine;
|
|
|
|
namespace CleverCrow.Fluid.BTs.Tasks {
|
|
public class RandomChance : ConditionBase {
|
|
public float chance = 1;
|
|
public float outOf = 1;
|
|
public int seed;
|
|
|
|
protected override bool OnUpdate () {
|
|
var oldState = Random.state;
|
|
|
|
if (seed != 0) {
|
|
Random.InitState(seed);
|
|
}
|
|
|
|
var percentage = chance / outOf;
|
|
var rng = Random.value;
|
|
|
|
if (seed != 0) {
|
|
Random.state = oldState;
|
|
}
|
|
|
|
return rng <= percentage;
|
|
}
|
|
}
|
|
}
|