Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Accessing generator's input spline in script, changing it at runtime
#1
Hello. I've gone thoroughly through the documentation, api reference, YouTube tutorials and searched here on the forums, but cannot find anything that can explain how I might reference a geneator's input spline path module and assign a spline that was created at runtime. I already have the spline created and configuredĀ at runtime and I have a reference to the generator in question, but I can't understand the method or module reference syntax etc. If someone could help it would be very appreciated. Thanks
Reply
#2
Hi
This post addresses your question: https://forum.curvyeditor.com/thread-435...ml#pid1572
Have a nice day
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#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
#4
Thanks for sharing. If and when you feel like it, please leave a review for the asset, that helps a lot.
Have a nice day
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  player stuck on spline Dextex 4 106 07-17-2021, 04:52 PM
Last Post: _Aka_
  Locking the UV's of a closed spline John_MLS 1 113 07-09-2021, 03:54 PM
Last Post: _Aka_
  Manipulate Generator properties in c#? blabz2007 9 548 06-18-2021, 09:17 AM
Last Post: _Aka_
  Updating MaterialID in MetaCGOptions at Runtime boriskourt 5 323 06-16-2021, 03:54 PM
Last Post: _Aka_

Forum Jump: