예제 #1
0
        public sealed override void OnUpdate(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent)
        {
            cachedSqrThreshold  = vfxValues.GetFloat(velocityThresholdPropertyId);
            cachedSqrThreshold *= cachedSqrThreshold;

            cachedRatePerSqrUnit  = vfxValues.GetFloat(ratePerUnitPropertyId);
            cachedRatePerSqrUnit *= cachedRatePerSqrUnit;

            if (!state.playing || state.deltaTime == 0)
            {
                return;
            }

            Vector3 pos         = vfxValues.GetVector3(positionPropertyId);
            float   sqrDistance = Vector3.SqrMagnitude(m_OldPosition - pos);

            if (sqrDistance < cachedSqrThreshold * state.deltaTime)
            {
                state.spawnCount += sqrDistance * cachedRatePerSqrUnit;

                state.vfxEventAttribute.SetVector3(oldPositionAttributeId, m_OldPosition);
                state.vfxEventAttribute.SetVector3(positionAttributeId, pos);
            }
            m_OldPosition = pos;
        }
예제 #2
0
        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;
        }
예제 #3
0
    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;
        }
    }
예제 #4
0
 public sealed override void OnPlay(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent)
 {
     m_OldPosition = vfxValues.GetVector3(positionPropertyId);
 }