Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Curvy Offset with Lerp
#1
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:
Code:
_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
Reply
#2
Hi,
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.
Reply
#3
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
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  UI button to start Curvy Spline in scene funkd 1 23 07-12-2019, 11:19 AM
Last Post: _Aka_
  Import Curvy from json Issue mlndb10wN 5 301 05-29-2019, 06:46 PM
Last Post: _Aka_
  Curvy Coppy all points of a Spline Into Another UsernameHed 3 302 05-13-2019, 11:37 AM
Last Post: _Aka_
Information Curvy 5.2.2 is live _Aka_ 0 160 04-30-2019, 11:00 AM
Last Post: _Aka_

Forum Jump: