Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Root Motion on Spline
#1
Good Afternoon, I'm currently trying to "constrain" my character to a spline, Setting its rotation with
 Vector3 P;                                       
    float carTf = path.GetNearestPointTF(transform.position, out P, Space.World); 
    Quaternion splineOrientation = path.GetOrientationFast(carTf);
    float splineOrientationYaw = splineOrientation.eulerAngles.y;
    transform.eulerAngles = new Vector3(0f, splineOrientationYaw, 0f);


this is going well for the rotation part, although for the movement along the spline, I'm trying to get a normalize length of the spline (0 to 1) depending on the current position of my character, is there a simple way to get this value? 

This is for stopping the player when he gets near the end or beginning of the spline.

Thank you and have a good day, excellent profuct by the way!
Reply
#2
Hi
Thank you for the compliment, always makes me happy to read them Smile
I think this is what you are looking for (possible typos)
var normalizedLength = spline.TfToDistance(carTf) / spline.Length;
Did it work?
Have a nice day

PS: being a French speaker, I found your nickname very funny, then I searched it on the internet. Thanks for making me discover what a puddingchomeur is Big Grin
Available for freelance work, feel free to reach out: toolbuddy.net
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Filling a closed spline dynamically rickgplus 1 230 04-16-2025, 08:56 AM
Last Post: _Aka_
  Disable a spline's gizmo when not selected or disabled. mikechr2000 1 285 02-03-2025, 09:34 AM
Last Post: _Aka_
Information Questions regarding spline colliders and collisions with rigidbodies Spyboticer 7 1,096 01-20-2025, 12:25 PM
Last Post: _Aka_
  Extrude mesh along spline. New and confused user GhostStalker 3 530 01-02-2025, 09:58 AM
Last Post: _Aka_

Forum Jump: