Download

Call tick when using UKismetMathLibrary::RInterpTo?

I am trying to make my character sit in a chair using C++. When the character overlaps the trigger volume and the player hits the E key I call a function called InitializeSittingProcess(AActor* actor). Here I store the actor it self (the chair in this example), the location and rotation and set the state of the character to SITTINGDOWN which is an enum value. In the tick function of the character I check the state and if it is SITTINGDOWN I call a Sit function like so (Note that the TargetRotation is the result from FindLookAtRotation on the chair and character) :



void ABubba::Sit()
{
FRotator RInterpToLookAt = UKismetMathLibrary::RInterpTo(GetActorRotation(), TargetRotation, FApp::GetDeltaTime(), 5.0f);

RInterpToLookAt.Pitch = 0.0f;
RInterpToLookAt.Roll = 0.0f;

SetActorRotation(RInterpToLookAt);
}

Is this the correct way to do it? Hence, do I need to check the state of the character on each tick? Or is it possible to just call the Sit function once and get a callback or something when it is done rotating?

Thanks for any help!