void UTargetTracker_indicator::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
if (ActorClassArrow&&ActorClassTarget&&GetOwner()&&IsNotSpawned)
{
FTransform OwnerTransform =GetOwner()->GetTransform();
CurrentLocation=OwnerTransform.GetLocation();
CurrentLocation.X += 100.0f;
OwnerTransform.SetLocation(CurrentLocation);
GetWorld()->SpawnActor<AActor>(ActorClassArrow,OwnerTransform);
IsNotSpawned=false;
}
if(!IsNotSpawned)
{
FVector NextLocation=GetOwner()->GetActorLocation();
NextLocation.X+=100.0f;
GEngine->AddOnScreenDebugMessage(-1,15.0f,FColor::Yellow, FString::Printf(TEXT("%s"),*GetOwner()->GetActorLocation().ToString()));
SetRelativeLocation(NextLocation);
}
// ...
}
Here’s my code. The arrow spawned but doesn’t move.