How would I smoothly blend to a location like you can do with cameras? I want an object to smoothly move from point a to point b, what is the easiest way to do this? Ideally i’m looking for a function like SetActorLocationWithBlend() if something like that exists
You could use FMath::VInterpTo (Smoothing is automatic) or FMath::Lerp(No automatic smoothing, uses linear curve)
@MiniTurtle
Thank you very much! I appreciate that. Could you show me how i’d implement that math function using SetActorLocation?
Foo.h
UCLASS()
class AFooCharacter : public ACharacter
{
GENERATED_BODY()
public:
virtual void Tick(float DeltaTime) override;
FVector TargetLoc;
};
Foo.cpp
void AFooCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
// Timer is for testing only
static float Timer = 0;
Timer -= DeltaTime;
if (Timer < 0)
{
TargetLoc.X = FMath::RandRange(-300, 300);
TargetLoc.Y = FMath::RandRange(-300, 300);
TargetLoc.Z = 300;
Timer = 3.f;
}
// How to interp
FVector NextLoc = FMath::VInterpTo(GetActorLocation(), TargetLoc, DeltaTime, 2.f);
SetActorLocation(NextLoc);
}
Note that collision will not work this way