I am trying to make a sprint function and I want to check to see if he’s going faster before I start any of the stuff but it won’t enter the if statement.
if (FVector::DotProduct(GetVelocity(), GetActorRotation().Vector()) > (OriginalWalkSpeed * 1.5)) {
if (SprintFloat) {
FOnTimelineFloat TimelineProgress;
FOnTimelineEventStatic TimelineEnd;
TimelineProgress.BindUFunction(this, FName("BeginSprintTimelineFunc"));
SprintTimeline.AddInterpFloat(SprintFloat, TimelineProgress);
SprintTimeline.SetLooping(false);
SprintTimeline.PlayFromStart();
GetWorld()->GetFirstPlayerController()->PlayerCameraManager->PlayCameraShake(CamShake, 1.f);
}
I know that it should work because I did that math in blueprint and printed it, it should enter to true. The weirdest part is it will enter the stop sprint if statement which is exactly the same.
if (FVector::DotProduct(GetVelocity(), GetActorRotation().Vector()) < (OriginalWalkSpeed * SprintMult)) {
if (SprintFloat) {
FOnTimelineFloat TimelineProgress;
FOnTimelineEventStatic TimelineEnd;
TimelineProgress.BindUFunction(this, FName("EndSprintTimelineFunc"));
SprintTimeline.AddInterpFloat(SprintFloat, TimelineProgress);
SprintTimeline.SetLooping(false);
SprintTimeline.PlayFromStart();
GetWorld()->GetFirstPlayerController()->PlayerCameraManager->StopAllInstancesOfCameraShake(CamShake, false);
}
}
Thanks in advance!