Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Curvy Offset with Lerp
Hello Smile

I have a little situation when I want to do a custom transition between 2 offset with curvy.

My goal is:

I have somes keys on a road, with a SplineController static on the keys, with different offset radius & angle.
Then I have a player, with a SplineController who follow the road. I want to lerp the offSet radius/angle of the player depending on the key before and after.

So Every frame, I'm doing my calculation, and here the result:

Basicly, I do:
_splineController.OffsetRadius = Mathf.Lerp(prevRadius, nextRadius, percent);
_splineController.OffsetAngle = Mathf.Lerp(prevAngle, nextAngle, percent);

prevRadius & prevAngle: the value of the previous gost Spline Controller (white car)
same with next for the next gost

The problem is durring the lerp, the car is going up and down in a circle, and it is logic from my code and yours...
But how can I do an offset lerp without this weird behavior ?

Thanks Smile
Try setting up your keys in a way that keeps the OffsetAngle always the same, and changing only the OffsetRadius between positive and negative values (instead of what I think you did, which is having the radius always positive and changing the angle). This way, you will not have to lerp the radius, which will avoid having your controller move outside of the road's plane.
Was my explanation clear?
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Ooh, I didn't thought about that ! Very nice, Thank you ! It solve my local problem here.
I am trying to think about a case where it doesn't work, but for now it work for all my situation.

Thanks you again Smile

Possibly Related Threads…
Thread Author Replies Views Last Post
  Additional offset to Follow behaviour Ayyappa 3 11 04-30-2024, 01:35 PM
Last Post: _Aka_
  Curvy Line Renderer for UI Spline? gekido 3 6 04-04-2024, 12:56 PM
Last Post: _Aka_
  8.8.0 is live, and it improves Curvy Generator greatly _Aka_ 1 12 04-03-2024, 03:16 PM
Last Post: _Aka_
  snap to the curve created by the curvy splines segment points ShiroeYamamoto 3 11 04-02-2024, 02:24 PM
Last Post: _Aka_

Forum Jump: