Hi everyone,
So I have a little problem and I don’t really know how to figure out.
I try to move a bullet I spaw, with my character to a target. I have do it in Blueprint and it’s work really good but I don’t know it’s not working in C++.
void ABullet::Reach_target()
{
if (target_position != FVector(0, 0, 0))
{
FVector destination;
destination = FMath::Lerp(GetActorLocation(), target_position, 0.05);
FLatentActionInfo Looll;
UKismetSystemLibrary::MoveComponentTo(GetMesh(), target_position, FRotator::ZeroRotator, false, false, 5.0f, EMoveComponentAction::Move, Looll);
if (GetActorLocation() == target_position)
{
this->Destroy(true);
UE_LOG(LogTemp, Warning, TEXT("MEURTTTTTTT"));
}
//GetWorldTimerManager().SetTimer(Timer, this, &ABullet::Reach_target, 0.1f, false);
}
}
I am sure the target is valid because i print it and it’s good, and I am sure too my fonction “Reach_target” is call and i go into the if, so it’s the function who doesn’t work i guess ?
I include in my cpp the #include “Kismet/KismetSystemLibrary.h”
What am I doing wrong ?