Hide a 3DWidget
Hi , i'm about to create a blueprint who allow to the players to see their names on top of each player with a 3DWidget. The problem is, that i want to hide the name if there is an object between the player field of view and the other names of the other players.
asked Jun 01 '17 at 05:36 PM in Blueprint Scripting
You're likely using the "Screen" option instead of the "World" option for your Widget component. In the settings for the Widget Component, change the Space option to World instead of Screen. Screen will render the text in screen space which means it will always clip in front of Objects in the world.
Let me know if this helps :)
You can use two checks to achieve that, first one that checks if the player is close enough to any of the other characters by looping trough all of them every 5th frame or so, then if some are close enough make another check using a line trace from the player to that/those characters to ascertain if the player can see them, (the only reason for delaying the checks somewhat is to try and minimize any performance impact if you are checking against many characters/complicated terrain collision).
This type of checking is kinda basic since it ignore foliage or other types of partially covered characters, but it should work for you at the moment based on your image so I would recommend it. You could also try and put up a system using ue4's perception components but hat involves more options and can sometimes be more complicated to use cleanly.
answered Jun 01 '17 at 05:57 PM
make an array of type actor reference in your character with references to all the enemies at begin play, either by making each enemy "add" self by casting or maybe as a temporary solution use a get all actors of type node if you only have one actor type atm.
do a foreach loop using that array.
Inside that loop make a branch and check the distance to the actor, (location - location < the distance you want), if true make a linetrace to that actor from you player character, if the trace returns the same actor as you are checking in your loop atm, (drag a node from the loop actor ref = it to the actor hit from the trace), then cast to that actor and run a function in it displaying its name.
Im at work atm, so I could possibly make a graph when I get home, hope that helped.
answered Jun 02 '17 at 08:15 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here