using UnityEngine; [AddComponentMenu("Modifiers/Warps/Bubble")] public class MegaBubbleWarp : MegaWarp { public float radius; public float falloff = 20f; private Matrix4x4 mat = default(Matrix4x4); public override string WarpName() { return "Bubble"; } public override string GetHelpURL() { return "?page_id=111"; } public override Vector3 Map(int i, Vector3 p) { p = tm.MultiplyPoint3x4(p); Vector3 a = p; float magnitude = p.magnitude; float t = Mathf.Exp((0f - totaldecay) * Mathf.Abs(magnitude)); float num = Vector3.Magnitude(p) / falloff; p += radius * Vector3.Normalize(p) / (num * num + 1f); p = Vector3.Lerp(a, p, t); return invtm.MultiplyPoint3x4(p); } private void Update() { Prepare(Decay); } public override bool Prepare(float decay) { totaldecay = Decay + decay; if (totaldecay < 0f) { totaldecay = 0f; } tm = base.transform.worldToLocalMatrix; invtm = tm.inverse; mat = Matrix4x4.identity; SetAxis(mat); return true; } }