Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Accessing generator's input spline in script, changing it at runtime
#3
Yep that did the trick thank you! For those who may come here in the future, here is my simple method for doing this which I derived from the infinite track scene.

// make spline, you can put in start or have it run once in update add at points to it.
if (!spline)
{
spline = CurvySpline.Create();
spline.Interpolation = CurvyInterpolation.CatmullRom;

buildGenerator();
}

// optional method of adding points to the spline at runtime, I have mine in a crappy frame skip. Make sure to refresh the generator after any change to the spline

if (i < 1)
{
spline.Add(transform.position);

gen.Refresh();

i++;
}
else if (i < 9)
{
i++;
}
else
{
spline.Add(fmpTransform.position);

gen.Refresh();

i = 0;

}

// build a generator
CurvyGenerator buildGenerator()
{
// Create the Curvy Generator
gen = CurvyGenerator.Create();
gen.AutoRefresh = false;
// Create Modules
InputSplinePath path = gen.AddModule<InputSplinePath>();
InputSplineShape shape = gen.AddModule<InputSplineShape>();
BuildShapeExtrusion extrude = gen.AddModule<BuildShapeExtrusion>();
BuildVolumeMesh vol = gen.AddModule<BuildVolumeMesh>();
CreateMesh msh = gen.AddModule<CreateMesh>();
// Create Links between modules
path.OutputByName["Path"].LinkTo(extrude.InputByName["Path"]);
shape.OutputByName["Shape"].LinkTo(extrude.InputByName["Cross"]);
extrude.OutputByName["Volume"].LinkTo(vol.InputByName["Volume"]);
vol.OutputByName["VMesh"].LinkTo(msh.InputByName["VMesh"]);
// Set module properties
path.Spline = spline;
path.UseCache = true;
CSRectangle rectShape = shape.SetManagedShape<CSRectangle>();
rectShape.Width = 20;
rectShape.Height = 2;
extrude.Optimize = false;
extrude.CrossHardEdges = true;
vol.Split = false;
vol.SetMaterial(0, mat);
vol.MaterialSetttings[0].SwapUV = true;

msh.Collider = CGColliderEnum.None;
return gen;
}
Reply


Messages In This Thread
RE: Accessing generator's input spline in script, changing it at runtime - by smackledorf - 06-17-2021, 08:46 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Set Volume to the Volume Controller at Runtime pako88 2 10 04-08-2024, 03:26 PM
Last Post: _Aka_
  Curvy Line Renderer for UI Spline? gekido 3 6 04-04-2024, 12:56 PM
Last Post: _Aka_
  8.8.0 is live, and it improves Curvy Generator greatly _Aka_ 1 10 04-03-2024, 03:16 PM
Last Post: _Aka_
  Get position of all control points for a spline gekido 1 6 03-28-2024, 10:08 PM
Last Post: _Aka_

Forum Jump: