Facepunch / sbox-issues

176 stars 12 forks source link

Create Particle Snapshots At Runtime #2613

Closed GunnarKafel closed 1 year ago

GunnarKafel commented 1 year ago

For?

S&Box

What can't you do?

I can't create a particle snapshot through C# then apply it to a particle system.

How would you like it to work?

I'd like to be able to build a snapshot through code, then pass it through a particle's SetSnapshot method

var snapshot = new ParticleSnapshot();

var point = new SnapshotVertex();
point.Position = Vector3.Zero;
point.CreationTime = 1f;
point.Normal = Vector3.Up;

snapshot.AddVertex(point);

particle.SetSnapshot(0, snapshot);

What have you tried?

I've tried using control points, but it's not very scalable with large particle counts.

Additional context

Half-Life Alyx uses these runtime snapshots for the Reviver storm and toner puzzle paths.

Reviver Storm: https://streamable.com/8gdnrc https://streamable.com/e0femp hlvr_99EtUoUsGB

Toner Puzzle: image 20221128231752_1 image

aylaylay commented 1 year ago

Hey that's not a bad idea

aylaylay commented 1 year ago

Merged this in, please test it and let me know if it works as expected.

GunnarKafel commented 1 year ago

Works perfectly, thank you!