Doors were closed

can you please tell me whats wrong with my code, it was compile well but doors were closed



You are never updating the values used.

TotalYaw = FMath::Lerp(currentYaw, TargetYaw, 0.02f); 

Is always going to yield the same value each tick.

1 Like

can you rewrite the code for better explanation , please

I was just highlighting the code you wrote.

Say TotalYaw and currentYaw is initially 0, and TargetYaw is 90.

Then the first call to TickComponent would do

TotalYaw = FMath::Lerp(0, 90, 0.02f); 

Which is 1.8. The next frame you do the exact same calculation.

TotalYaw = FMath::Lerp(0., 90, 0.02f); 

So TotalYaw will initially be 0 and then always be 1.8 after that. What is done in the course is to use the updated value. i.e.

TotalYaw = FMath::Lerp(TotalYaw, TargetYaw, 0.02f); 

That means on the first call to tick it would be the same as before however on the next call it will be using that updated value e.g.

TotalYaw = FMath::Lerp(1.8, 90, 0.02f); 

Which means TotalYaw would be updated to the value 3.564 and then the same thing will happen with that value.

1 Like

thank you so much

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms