05-24-2024, 08:41 AM
Hi,
I hope this helped.
If and when you feel like it, please leave a review for the asset, that helps a lot.
Have a nice day
Code:
using FluffyUnderware.Curvy;
using UnityEngine;
public class SpeedMetaData : CurvyInterpolatableMetadataBase<float>
{
[SerializeField]
private float m_Speed;
public override float MetaDataValue => m_Speed;
public override float Interpolate(
CurvyInterpolatableMetadataBase<float> nextMetadata,
float interpolationTime)
{
if (nextMetadata == null)
return MetaDataValue;
return Mathf.Lerp(
MetaDataValue,
nextMetadata.MetaDataValue,
interpolationTime
);
}
}Code:
using FluffyUnderware.Curvy.Controllers;
using UnityEngine;
public class TestSplineController : SplineController
{
/// <summary>
/// This is called just after the SplineController has been initialized
/// </summary>
protected override void UserAfterInit() =>
SetSpeed();
/// <summary>
/// Called after the controller has updated it's position or rotation
/// </summary>
protected override void UserAfterUpdate() =>
SetSpeed();
private void SetSpeed()
{
// Get the interpolated Metadata value for the current position (for SplineController, RelativePosition means TF)
// If values can't be interpolated (no next value), current value (if present) or default type value (for float that's 0) is returned
Speed = Spline.GetInterpolatedMetadata<SpeedMetaData, float>(RelativePosition);
Debug.Log(Speed);
}
}I hope this helped.
If and when you feel like it, please leave a review for the asset, that helps a lot.
Have a nice day
Available for freelance work, feel free to reach out: toolbuddy.net
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Please consider leaving a review for Curvy, this helps immensely. Thank you.

