0

Chronos and VFXGraph

Seldemirov Pavel 7 months ago updated by Metervara 1 month ago 1

Hello! I want use my Cronus for record time in the VFXGrapn. How can I do it? How?

Chronos Version:
Unity Version:
2019.3

Hi,

if you just need to control the playRate of a VFX Graph you can create a new component inheriting from ComponentTimeline:

public class VFXGraphTimeline : ComponentTimeline<VisualEffect>
{
    public VFXGraphTimeline(Timeline timeline, VisualEffect component) : base(timeline, component) { }

    public override void AdjustProperties(float timeScale)
	{
        component.playRate = timeScale;
	}
}

then add that to the CacheComponents method of TimelineEffector:

// VFX Graph
var vfxGraphComponent = GetComponent<VisualEffect>();

if (vfxGraph == null && vfxGraphComponent != null)
{
	vfxGraph = new VFXGraphTimeline(timeline, vfxGraphComponent);
	vfxGraph.Initialize();
	components.Add(vfxGraph);
}
else if (vfxGraph != null && vfxGraphComponent == null)
{
	vfxGraph = null;
}

Then attach a Timeline Component to the GameObject with the Visual Effect

This only keeps the playRate synced with the timeline, probably won't work if reversing (negative time scale).