I’m making an animation notify which I want to smoothly move the character forward in the direction of their current facing. Since I want smooth motion instead of teleportation I’m using VInterpTo:
void UMovementNotifyState::NotifyBegin(USkeletalMeshComponent * MeshComp, UAnimSequenceBase * Animation, float TotalDuration){
myActor = Cast<AActor>(MeshComp->GetOwner()); //Cache a reference to the ACharacter to be moved, as an actor
if (myActor != nullptr){ //Sanity check to prevent Persona crashing
startLocation = myActor->GetActorLocation(); //Set the starting node to our current position
endLocation = myActor->GetActorForwardVector()*moveDistance; //Set the ending node to a position float moveDistance unreal units forward of our current facing
}
}
void UMovementNotifyState::NotifyTick(USkeletalMeshComponent * MeshComp, UAnimSequenceBase * Animation, float FrameDeltaTime){
if (myActor != nullptr){//Sanity check
myActor->SetActorLocation(FMath::VInterpTo(startLocation, endLocation, FrameDeltaTime, 2.0)); //Lerp us towards the desired destination
}
}
I’m expecting this to propel the character forward each tick, but instead the character remains in place, occasionally bobbing up and down vertically but never moving horizontally. Is the problem just my vector math, or am I mis-using vinterpto?