- Home /
Object Scale Lerp with rigidbody addforce jump duration.
Hi there, I'm a little stuck on a problem where I need to scale an object while it is going up, and then return the scale as it falls.
I figured I'd lerp for the transition. I'm just stuck on how to get the duration of the jump up to its peak acceleration point and then do the opposite and convert the peak to the ground plane in time. Pseudo:
Vector3.Lerp(originalScale, smallScale, TIME);
Vector3.Lerp(smallScale, originalScale, TIME);
Jump is done via
rb.AddForce(Vector3.up * forceValue), ForceMode.Impulse);
Thanks for your time.
I mean, there are a couple of hackey ways to do this. One I can think of is use your update loop to measure velocity and keep time. Once velocity is 0(or very close with some threshold) then you know you are at your peak. Stop your timer at this point and now you have your time. Someone with more of a physics background could probably answer this question better.
Answer by TheSorm · Apr 21, 2016 at 05:17 PM
You dont need that Lerp stuff i think. You can just write it in the Update() Methode.
void Update () {
if( object.x > ground.x) {
object.scale = object.x - ground.x;
}
}
This is not working code but i hope you understand what i mean. and if it is importend how big it will scale you can just try out how big the differnce between ground and player is at the highest point and than calculate the scale factore.