I’m familiar with the FMath::FInterpTo
method. It works as expected here:
void AMyCharacter::Tick(float DeltaSeconds) {
Result = FMath::FInterpTo(Result, 0, DeltaSeconds, 20.0f);
Super::Tick(DeltaSeconds);
}
However, FInterpTo
applies an “ease out”.
Instead, I would like an “ease in”. So I want to use FMath::InterpEaseIn
which should do just that.
I tried using it like this:
void AMyCharacter::Tick(float DeltaSeconds) {
Result = FMath::InterpEaseIn<float>(Result, 0, DeltaSeconds, 90.0f);
Super::Tick(DeltaSeconds);
}
But this literally doesn’t do anything; Result
is never changed.
How do I correctly apply an “ease in” interpolation?
Your issue here is you are using DeltaSeconds where it should be an alpha. The alpha here is a value between 0 and 1, at 1 the float will be a max, at 0 it will be at the starting value. If you want for example the item to reach the end point in 1 second, rather than passing in Delta seconds pass in a value that is incremented by DaltaSeconds each run of the Tick. For example:
void AMyCharacter::Tick(float DeltaSeconds) {
float secondsToFinish = 1.0f;
Alpha += (DeltaSeconds / secondsToFinish);
Result = FMath::InterpEaseIn<float>(Result, 0, Alpha, 90.0f);
Super::Tick(DeltaSeconds);
}
In the above change the secondsToFinish value to increase the amount of time the Interp will take to get to the end.
guitou80
(guitou80)
February 24, 2023, 6:55pm
3
Robert Penner equations are awesome :
float Elastic::easeOut(float t,float b , float c, float d) {
if (t==0) return b; if ((t/=d)==1) return b+c;
float p=d*.3f;
float a=c;
float s=p/4;
return (a*pow(2,-10*t) * sin( (t*d-s)*(2*PI)/p ) + c + b);
}
t is time, d is duration, c is the offset, b is initial value