Skip to content

UMageItWorldMarkerComponent

Base Class: USceneComponent

UMageItWorldMarkerComponent is the bridge between your 3D game world and your 2D UI. You attach this component to any Actor in your level (e.g., an enemy, a quest NPC, a loot drop, or a capture point).

Because it inherits from USceneComponent, it has a physical location in the 3D world. On BeginPlay, it automatically registers itself with the UMageItWorldMarkersSubsystem and provides the necessary configuration (like which UI widget to spawn, how far away it can be seen, and whether it sticks to the screen edges).


These properties can be configured directly in the Details Panel of the Actor Blueprint where you added this component.

  • WidgetClass (TSubclassOf<UMageItWorldMarkerWidget>): The specific Blueprint UI class that will be spawned to represent this marker on the screen.
  • bStickToViewport (Boolean): If enabled, the marker will clamp to the edge of the screen when the Actor is not in the camera’s view. If disabled, the marker will disappear when looking away.
  • MarkerSize (FVector2D): The logical dimensions of the UI widget. This is critical for calculating accurate screen edge collisions and padding.
  • ScreenEdgeGap (FMargin): Padding applied when the marker is clamped to the edge of the screen, preventing it from clipping outside the monitor bounds.
  • bEnabled (Boolean): Determines if the marker should be processed and rendered at all. Can be toggled at runtime.
  • bCrosshairInteractionEnabled (Boolean): Allows this specific marker to respond to crosshair focus events (useful for interactive objects).
  • MaxVisibleDistance (Float): The maximum distance (in Unreal Units / cm) from the player at which this marker is visible. Set to 0.0 for infinite distance.

You can call these methods on the component at runtime to dynamically control its behavior.

  • EnableMarker() / DisableMarker() Safely turns the marker on or off. This updates the subsystem and triggers visibility changes in the UI.
  • GetMarkerWidget() Returns the instantiated UMageItWorldMarkerWidget (UI element) associated with this component. You can cast this to your specific Blueprint widget class to update custom data (e.g., setting health bar values or changing text).
  • HasValidMarkerWidget() Returns true if the UI widget has been successfully created and is currently valid.
  • GetDistanceToPlayer() Returns the exact distance (in cm) from this component to the target player’s camera.
  • GetDistanceToPlayerSquared() Returns the squared distance. Use this instead of GetDistanceToPlayer when doing frequent comparisons (like sorting arrays) as it is significantly cheaper on the CPU since it avoids square root calculations.

These functions can be overridden in your custom Blueprint child classes to inject your own game-specific logic.

  • IsVisibleForPlayer() (Returns Boolean) Override this function to add custom conditions for visibility. For example, you can make a marker visible only if the player has a specific item in their inventory, or if the enemy is fully “spotted” by teammates.
  • IsAlwaysVisibleForPlayer() (Returns Boolean) If this returns true, the subsystem will skip conditional visibility checks.
  • GetTagetPlayerController() (Returns APlayerController) By default, the component registers with the local player. Override this if you are doing complex splitscreen or spectator setups where a marker belongs to a specific controller.