Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Controler Speed from metadata
#1
I as trying to modify the height metadata script to control the speed, without success. How can I accomplish this? Thanks.
Reply
#2
Hi,

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
Please consider leaving a review for Curvy Splines, this helps immensely. Thank you.
Reply
#3
Thank you for your reply! Is there an easy way to add the SpeedMetaData component the control points automatically while the spline is being created?
Reply
#4
Thank you for your reply! Is there an easy way to add the SpeedMetaData component the control points automatically while the spline is being created?
Reply
#5
I see different ways, one of them being to create a script that would listen to the OnRefresh event of active splines in the scene, and on each refresh to make sure that all the splines` control points have a SpeedMetaData component attached to them.
The main members to use:
CurvySpline.OnRefresh
CurvySpline.ControlPointsList
Did this help?
Please consider leaving a review for Curvy Splines, this helps immensely. Thank you.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Smile Constant speed along a spline? tfishell 1 1,190 11-13-2025, 11:32 AM
Last Post: _Aka_
  "MetaData" Of Entire Spline Heightmap SAMYTHEBIGJUICY 3 3,416 10-16-2023, 08:42 AM
Last Post: _Aka_
  Metadata interpolation tairoark 3 3,013 10-17-2022, 01:07 PM
Last Post: _Aka_
  Proper metadata usage tairoark 2 2,532 10-01-2022, 12:04 PM
Last Post: _Aka_

Forum Jump: