Hi.
Last few hours I was trying to calculate acceleration of player movement.
I’m use school formula
v0-v/t,
but something works wrong.
My person start moving with speed 0 and just in 1.5 second he just run ahead with 230.f (2.3m/s) speed.
Here is no light speed up (Like in GTA5, or Witcher 3).
What I’m do:
I have variables:
Acceleration = 70.f;
CurrentSpeed = 0.f;
TimeTook = 0.f;
MaxSpeed = 230.f;
TimeTook is variable that told how many time player hold on press movement buttons.
Alson I know the distance I walk while buttons pressed. (But I don’t know how to make this usefull).
And after using formula trying to calculate hero movement speed but all is useless.
Can anybody help me with this or maybe give an advice how can I fix it? Cause I feel myself very stupid and broken at moment. It’s really very ugly feelings when you can’t resolve simple math task.
Thanks.
UPD
How I handle time.
When user press button a log the time:
PressMoveButtonTime = FDateTime::UtcNow();
After, depending on that I calculate how many time button was pressed:
float seconds = (FDateTime::UtcNow() - PressMoveButtonTime).GetSeconds();
UE_LOG(LogTemp, Warning, TEXT("Time = %s"), *FString::SanitizeFloat(seconds));