Today I was working on a rangefinder for my first game, everything wokrs fine, but I want a nice way to display it at the location of the enemy, so not on my HUD, but more like a text render or something. I have something working with a add text render, but I can’t remove it and it doesn’t look that good.
And for if it matters, it is a FPS project, I can get the enemy’s location, range to player etc.
Text render is probably the way to go, you can add it as a component or wrap it in a component and have it as part of your enemy blueprint. Place it above their head or so.
Making it look good is about tweaking the font, add a sprite around it and such to make it look right.
Once it’s within the enemy blueprint, turning it on and off can be done by the blueprint or by the player with get all actors of class → enemy blueprint → call a function on enemy blueprint.
If you’re open to having it as part of the widget layer, though not actually part of your stationary HUD, you can use the “Project World Location to Widget Position” node inside a widget to place it at a place that corresponds to a world location.
That looks like it’s about right. You just forgot to hook up your actual widget as the target of your “Set Position in Viewport” node, so you are never actually setting the position of the widget.
Sorry but I don’t get this, because I can’t hook up my text, but if I create a widget using the create widget node, I would use the widget i am making this blueprint in, won’t that mean that I can just use the self reference?
And I tried the Project World location to get position as well as the ConvertWorldLocaitonToScreenLocation node.
I also played around with conecting things from the Event construct. And the target of the set visibility node.
You can’t create your widget from inside a widget that hasn’t been created. Something outside your widget needs to create your widget in the first place (and if your RangeFinder widget then created another RangeFinder widget during construction, you would set off a chain of infinite RangeFinder widgets being created.)