Metadata

Sometimes you want to store additional information to your spline, e.g. a max speed or other track information for your racing track, additional Curvy Generator data etc..

This is done by creating your own Metadata classes and attaching them to Control Points. You then can use Curvy Splines' API to access that data.

Metadata interpolation

When assigning a Metadata to a Control Point, the Metadata's value is applied to the segment starting from said Control Point until the next one. When there is no Metadata interpolation, the value of the Metadata will suddenlty change one you reach the next Control Point. Sometimes, you want that value to be gradually interpolated between the two Control Points. That's when interpolatable Metadata comes into play.

Creating the Metadata class

Create a new MonoBehaviour that inherits from one of the following classes:

Here is an example (used by the Metadata example scene) that provides a simple float value that can be interpolated:

namespace FluffyUnderware.Curvy.Examples
{
    public class HeightMetadata : CurvyInterpolatableMetadataBase<float>
    {
        [SerializeField]
        [RangeEx(0, 1, Slider = true)]
        float m_Height;
 
        public override float MetaDataValue
        {
            get { return m_Height; }
        }
 
        public override float Interpolate(CurvyInterpolatableMetadataBase<float> nextMetadata, float interpolationTime)
        {
            return (nextMetadata != null) ? Mathf.Lerp(MetaDataValue, nextMetadata.MetaDataValue, interpolationTime) : MetaDataValue;
        }
    }
}

Assigning Metadata to Control Points

As Metadata classes are regular MonoBehaviours, simply add them to the desired Control Points using the Component menu.

Retrieving Metadata

You can access Metadata from Splines and from Control Points using the following API members:

For example, the MetadataController script from the example scene mentioned above uses the following code to access the height value:

float height = Spline.GetInterpolatedMetadata<HeightMetadata,float>(RelativePosition);