Custom text for 3D Widget - Get all Actors of Class
I'm trying to get specific actors from my level and then display a custom text on each of them (that has already been assigned on the specific actor instances in the level through a variable).
This is my widget, where I just have a plain text, which is changed through a variable that is located on the 3D Widget actor I am to use in the level (this is where I'm not sure what I'm doing wrong);
This is the 3D Widget in the level, that I try to display with a custom text (they are all the same actor, just copy pasted);
And lastly the Actor that has the 3D Widget with the variable "LevelText" that is set to editable. So that I can have a custom text on each instanced actor.
My problem is with the "Get All Actors of Class" node, not sure how to do it for each instanced actor. Tried searching around, I do get examples of other things, bot haven't found an example for my issue.
asked Aug 23 '17 at 11:51 PM in Blueprint Scripting
I eventually found a solution for this (as seen below).
My solution for this was to have two different blueprints, one widget blueprint and one actor blueprint. The widget blueprint is just a "Canvas Panel" and a "Text Box", where the "Canvas Panel" has a width of 250 and a height of 100 (this is just up to how you want it).
The actor blueprint is the blueprint that will display the widget blueprint as a 3D Widget in the game world. So this is basically the only thing I did:
On "even begin play" I cast to "Widget_LevelText" (which is my widget blueprint), with a reference of that widget blueprint connected to "Get user widget object" and then connected to "Object" on the cast node. I then get the text box from the widget blueprint, set a new text for it with "SetText (Text)" node, which has an editable text variable attached to it.
So now I can basically just copy paste the actor blueprint wherever I want in the game world, and rename each one to have their own specific text attached to it.
And that's how I did it! :) If you know of a more cost-effective way to do it (not sure how cost-effective this is), then please do send me a message!
Follow this question
Once you sign in you will be able to subscribe for any updates here