Hi everyone. I am a newbie at Unreal Engine. I have been working with Unity Engine for the past 6 years. I had dabbled with Unreal, but now I am converting a project to Unreal 5.7. I am hoping that someone will notice my mistake here. Below is C++ code that gets an array of targets that will feed my Radar 3D Widget. I am having no luck getting it to work. I gather that it may be my Blueprint that I might be getting wrong.
Code that creates the array of objects:
void URadarComponent::ProcessActor(AActor* Actor)
{
if (!Actor || !Actor->GetClass()->ImplementsInterface(UDetectableInterface::StaticClass()))
return;
AActor* Owner = GetOwner();
if (!Owner || !Actor) return;
FVector OwnerLocation = Owner->GetActorLocation();
FVector TargetLocation = Actor->GetActorLocation();
// World delta
FVector Delta = TargetLocation - OwnerLocation;
// š“ Convert to LOCAL SPACE (this fixes radar direction)
FVector LocalDelta = Owner->GetActorTransform().InverseTransformVectorNoScale(Delta);
FRadarContact Contact;
Contact.Actor = Actor;
Contact.WorldLocation = TargetLocation;
Contact.Location = TargetLocation;
// Distance (world)
Contact.Distance = Delta.Size();
// Use LOCAL Z (not world Z)
Contact.RelativeZ = LocalDelta.Z;
// ā THIS is what your widget actually needs
Contact.LocalOffset = LocalDelta;
if (Contact.Distance > RadarRange)
{
return; // š“ HARD FILTER (fixes ghost contacts)
}
// TEMP: bypass interface for debugging
Contact.ObjectType = ERadarObjectType::Ship;
AShipPawn* Other = Cast<AShipPawn>(Actor);
AShipPawn* Self = Cast<AShipPawn>(Owner);
if (Self && Other)
{
Contact.Race = Other->Race;
Contact.Affiliation =
IDetectableInterface::Execute_GetAffiliationTowardsRace(Self, Other->Race);
}
else
{
Contact.Race = ERadarRace::Unknown;
Contact.Affiliation = ERadarAffiliation::Unknown;
}
RadarContacts.Add(Contact);
UE_LOG(LogTemp, Warning,
TEXT("Added Contact: %s | Distance: %.0f"),
*Actor->GetName(),
Contact.Distance);
}
And here is the blueprint.
