I am doing a multiplayer game and I have added a long time ago the name above the player.
The thing is that I am not happy with my solution.
The way I added widget above player head is by creating a widget (with the name) add it to the player and NPC blueprint, and then select the following option : Space : screen.
The problem is that if the NPC, or the other player is not visible (hidden by a wall, a tree…) then the name is still appearing.
So, I tried to change the space by the world space and now the name is correctly hidden when player or NPC is hidden.
BUT, I still have an issue with it because then, if I arrived behind the player / NPC or on the side, I can’t read the name.
Looks like you want an in-world widget that is always facing camera.
Afaik there is no builtin solution for this, so you have to make it yourself.
Here is a sample blueprint code that should maintain the widget (or any component) straight and facing local player camera regardless of its relative/inherited transform :
Well rather than iterating all npc’s and their widgets, a simpler approach would have been to create a child class of the widget component and put the camera facing code there. Then replace the widget components in your characters with the new component.
But I respect your desire to avoid Tick, which is the better practice.
Here is a different method which uses screen widget, and toggles visibility according to whether the NPC is being rendered on screen or not. Big advantage is that it can run in a slower timer instead of Tick, and you can tweak the interval to balance optimization vs. feeling :
Thank you for your answer. But it is still not a really good solution I think because you use an event tick and it is not a good thing in multiplayer.
Also, the problem is for NPC and other player name. So I can’t do an event tick on my player character that take at each tick all the widget of all npc and then change the rotation of them.
The only way I have found for the moment is to make it like a screen widget and not a world widget, and then make it appear or disappear depending of the distance (do that using a box collision and begin overlap and end overlap event using visibility of the name widget). It is not a solution for people that would like to have always the widget visible, but I think it is what I will do if I haven’t better solution.
Oh, I didn’t know that this node exist (was component recentrly rendered), really good to know !
Thank you a lot for your help ! I think I will use it for many things haha.