How to attach widget to head of enemy character?

How to attach widget to head of enemy character which will be scaled always the same and positioned correctly? Everything what I have tried not working, widget always incorrectly positioned. Please send me solution, help me to create such functionality! How to create widget correctly and how to position widget above head which will be always correct showed??

Please help.

Ruslan

Hello @Ruslanmin2 ,
You could try the following.

Add a Widget Component to your enemy character. Then add the following logic to Event Tick so the widget always faces the player’s camera.

This keeps the widget attached to the character while ensuring it is always readable from the player’s point of view.

For the widget itself, you can create it however you like. In my example, I simply used a Canvas Panel with an Image and a Text widget, both anchored to the center.

With this setup, the widget attached to your enemy should always be displayed correctly.
If not, could you provide more details about what you’re trying to achieve? A more specific example would make it easier to understand the exact behavior you’re looking for and suggest a more appropriate solution.

Hope it helps!

I find it’s usually better to just attach the widget to capsule, and move it so it’s just above head in BP viewport. Attaching it to a bone or socket tends to make it jump around as the character animates. If you scroll way down in the details tab of the widget component to User Interface, and set space to “Screen” it will retain the Draw Size values just below that no mater how far away it is. Will probably want to set visibility to hidden if you do it this way tho while npcs are out of combat tho. So the screen isn’t full of health bars/nameplates from every enemy in the world.

In my action-rpg project, all the characters have an event which fires when health changes. In that I first set helthbar to visible, then set a timer for 6 seconds, which fires another event to set it back to hidden.

I want to attach widget to bone, and also use Space of Widget “Screen”. Widget the same as you designed!

Hi, please follow these steps to achieve what you want:

  1. Create a new User Widget with an Overlay as the main parent in the hierarchy, and add your child widget.

  2. Add a Widget Component to the character and place it as a child under the mesh component

  3. Select the Widget Component, set the Widget Class, then change the Space to Screen. So, under the Sockets category, choose a bone you want to attach it to.

I am creating widget like that:

Also creating widget dynamically im blueprint and attach to head socket:

But I getting such problems with positioning of widget above head:

How I can correctly position widget above head which will always showed correctly no matter which distance to enemy character??

Please help me!

Ruslan

(post deleted by author)

I have already shared the solution. The issue is the offset from the center in your widget. Please use Overlay (I mentioned this before) as the parent instead of Canvas, and ensure the marker is exactly centered in your widget.

Please don’t forget to mark it as the answer to the topic :slight_smile: