+1

Chronos and VFXGraph

Seldemirov Pavel 1 year ago updated by Benni 2 weeks ago 2

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

Chronos Version:
Unity Version:
2019.3
+1

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).

Dear Metervara,

I implemented the above, and it works if I have a delta time node in the vfx graph, but I have a problem where I want to slow down vfx graph on the whole, without referencing delta time. Is that possible with Chronos?  Thanks Ben