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
  Curvy 7.1.1 is live _Aka_ 2 105 09-04-2020, 08:09 AM
Last Post: _Aka_
  road crossings like T-Crossing or X-Crossing with Curvy? Econt 1 137 08-13-2020, 01:07 PM
Last Post: _Aka_
  Movement on Curvy with MouseWheel staticdreams 1 300 06-22-2020, 12:13 PM
Last Post: _Aka_
  Rotation of Curvy Spline Segment jh092 1 372 05-31-2020, 09:36 AM
Last Post: _Aka_

Forum Jump: