public static Sequence Shake(FGetter <Vector3> getter, FSetter <Vector3> setter, Vector3 offset, float time, Vector3 strength, int vibrato = 2, float randomness = 2, bool fade = true, Random rnd = null) { if (rnd == null) { rnd = new Random(); } Sequence seq = new Sequence(); int steps = vibrato + 1; int equality = rnd.Next(0, 2); for (int i = 1; i <= steps; i++) { Vector3 random = FlaxEngine.Utilities.Extensions.NextVector3(rnd, -randomness, randomness); Vector3 endVal = random + strength * (i % 2 == equality ? -1 : 1); float dur = time / steps; if (fade) { endVal = endVal * (1 - (i / steps)); dur = ((2 * time - 2 * (steps + 1)) / (steps * (steps + 1))) * i; Debug.Log(dur); } if (i == 1) { dur /= 2; } else if (i == steps) { dur /= 2; endVal = Vector3.Zero; } seq.Append(new Vector3FTweener(getter, setter, endVal + offset, dur).SetEase(Ease.Linear)); } return(seq); }
public static Sequence Jump(FGetter <Vector2> getter, FSetter <Vector2> setter, Vector2 offset, float time, Vector2 strength, int jumps = 10, float randomness = 90, Random rnd = null) { if (rnd == null) { rnd = new Random(); } Sequence seq = new Sequence(); int steps = jumps * 2; int equality = rnd.Next(0, 2); for (int i = 1; i <= steps; i++) { Vector2 random = FlaxEngine.Utilities.Extensions.NextVector2(rnd, -randomness, randomness); Vector2 endVal = (i % 2 == 0 ? Vector2.Zero : random) + strength * (i % 2 == 0 ? 0 : 1); float dur = time / steps; seq.Append(new Vector2FTweener(getter, setter, endVal + offset, dur).SetEase(Ease.Linear)); } return(seq); }
public QuaternionFTweener(FGetter <Quaternion> getter, FSetter <Quaternion> setter, Quaternion end, float time) : base(getter, setter, end, time) { }
public static Sequence Jump(FGetter <Vector2> getter, FSetter <Vector2> setter, Vector2 offset, float time, float strength = 90, int jumps = 10, float randomness = 90, Random rnd = null) { return(Jump(getter, setter, offset, time, new Vector2(strength), jumps, randomness, rnd)); }
public static Sequence Shake(FGetter <Vector2> getter, FSetter <Vector2> setter, Vector2 offset, float time, float strength = 2, int vibrato = 2, float randomness = 2, bool fade = true, Random rnd = null) { return(Shake(getter, setter, offset, time, new Vector2(strength), vibrato, randomness, fade, rnd)); }
public Vector2FTweener(FGetter <Vector2> getter, FSetter <Vector2> setter, Vector2 end, float time) : base(getter, setter, end, time) { }
public ColorFTweener(FGetter <Color> getter, FSetter <Color> setter, Color end, float time) : base(getter, setter, end, time) { }
public FloatFTweener(FGetter <float> getter, FSetter <float> setter, float end, float time) : base(getter, setter, end, time) { }