12-27-2023, 09:59 PM
(12-23-2023, 01:39 PM)_Aka_ Wrote: Hi Samy,
I would be surprised if the issue is due to outdate cache, but I stay open to this possibility. The problem not being easily reproducible makes it difficult to debug, but let's try something: Before using a spline in your code, force it to refresh by calling spine.Refresh().
In the lack of a reproduction case, what I suspect is a potential lack of precision in the data used to compute the tangent.
You use GetTangentByDistance. This one compares to neighboring point's position to deduce the tangent. Neighboring in this context is 0.01 tf difference. For a very long spline, 0.01 tf can be a significant distance.
If this is the issue, then I seen two solutions (and at the same time ways to confirm or not that this is the issue):
1- Use GetTangentByDistanceFast: this one used the spline's cache. You can control the caches's density in the spline's settings.
2- Modify GetTangentByDistance's code to make the delta a value other than 0.01 tf.
I hope this helped.
Have a great
PS:
Looking at your code, I see something that bothers me:
delta *= Time.deltaTime;
lastcornerangle += delta;
I don't know where lastcornerangle and delta are used later on, so maybe this code is doing what it shoudl be, but the multipication with deltaTime seems weird to me.
Totally fair and I'll try to do more investigating and make the suggested changes. You're right that the multiplication by time.deltatime there is a bit unorthodox but it's just another way to apply smoothing to an ongoing changing variable. It's like when you sometimes see currentvalue = mathf.lerp(currentvalue, targetvalue, time.deltatime). Technically not the way it was intended to be implemented but it works as a hack. I'm glad I only showed you this snippet of my code because if you saw the rest you would call the policeĀ