UI Radar Widget positioning not working for me.

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.

Hi there, maybe I’m mistaken, but this does look a bit AI interfered, correct me if I am wrong, and AI tends to make things worse when the architecture itself is not understood first. (Don’t get me wrong wanted to point it out) You have quite an experience with Unity too so this shouldn’t be too hard.

The bigger issue here is not one node or one line of code. It is that too many responsibilities seem to be mixed together.

You need separation of concerns. Maybe we should start with ProcessActor refactoring.

Think of the radar as a bucket/container. Its job is just to contain contacts. It does not need to know everything about what each contact is doing.

Each blip/contact can know its own type, center actor, max range, update its own position, and remove itself when no longer valid.

So the radar should mostly manage what is inside it, not micromanage the behavior of every single widget.

Right now there is a lot happening in one function / graph, so the problem could be coming from many places. That is why it is hard to diagnose directly from this post.

I would first clean up the ownership and responsibility of the system. After that, the actual bug will be much easier to find.

I would start with first common functions like if we are going to do with same approach.

RegisterContact // If an actor should and can be registered adds to array/ struct
DeregisterContact // removes and actor from array struct
GetCurrentContacts // Returns all actors in our dictionary
ShouldRenderContact // Checks their state (On Tick or Cron), if not calls Deregister (probably not needed)
UpdateContacts // Makes the rendering job and all representation.

On Update contacts you can create TMap of actors or widgets if not created and update in radar. As batch process and efficiency its good, but I usally delegate responsibility to widgets so they can do their jobs. It’s a trade off but I generally find this approach more elegant than others.

Do let me know and a similar BP only a while ago i did something for another topic which is really bare bones radar can be found here (Your needs seems much more than this but could work)

You are correct. I am not the seasoned C++ developer I’d like to be. Blueprints seem a lot like visual development to Unity, but I am still on a learning curve. I did, however, rely on the suggested architecture from AI. I am looking over the notes that you’ve given me. This was all working in C# in Unity, but it was not very efficient. Thanks for the reply.

It’s ok, as you know unfortunately game development is sometimes learn and forget then relearn again (cause its needed so async load memory :slight_smile: so welcome to the club)

Can you show a SS of the widget maybe even a video of it, or something similar? Cause you know there are many type of radars/scanners and interaction and behaviour vary, so does the architecture.

Maybe I can provide a better to the point answer to you.