public sealed override void OnUpdate(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent) { if (!state.playing || state.deltaTime == 0) { return; } float threshold = vfxValues.GetFloat(velocityThresholdPropertyId); Vector3 pos = vfxValues.GetVector3(positionPropertyId); float dist = Vector3.Magnitude(m_OldPosition - pos); if (threshold <= 0.0f || dist < threshold * state.deltaTime) { float count = dist * vfxValues.GetFloat(ratePerUnitPropertyId); if (vfxValues.GetBool(clampToOnePropertyId)) { count = Mathf.Min(count, 1.0f); } state.spawnCount += count; state.vfxEventAttribute.SetVector3(oldPositionAttributeId, m_OldPosition); state.vfxEventAttribute.SetVector3(positionAttributeId, pos); } m_OldPosition = pos; }
public override void OnUpdate(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent) { Vector3 checkPosition = vfxValues.GetVector3(CheckPositionID); float maxDistance = vfxValues.GetFloat(MaxDistanceID); bool InvertCheck = vfxValues.GetBool(InvertCheckID); Vector3 position = state.vfxEventAttribute.GetVector3(AttribPositionID); bool test = (checkPosition - position).sqrMagnitude > (maxDistance * maxDistance); if (test != InvertCheck) { state.spawnCount = 0; } }