Calling an element from a string array for text generation in a widget
im having difficulties assigning random names for NPCs in my game world. ive tried casting to the NPC and pulling the variable from the name library array but i cant figure out the object referenced in the "cast-to" node. ive tried calling and assigning the name locally from within the widget text block functions but it keeps randomly generating the names and changing the displayed name like a never stopping slot machine. i either need an object i can reference for the cast to or how to get the function to roll the once and commit to it for the text
asked Feb 19 '19 at 06:54 PM in Blueprint Scripting
If this is for an NPC HUD display or something you are going about it in the wrong way. You should have the NPC reference its personal widget and pass data from itself to the widget function. Not code the widget to get the NPC and get info from the NPC. Video #25 goes over references in detail, it might be helpful for you. Specifically watching at 14:25 I talk about referencing a widget. Now this is a viewport widget which if it is on your NPC you would get the reference slightly differently. From your NPC drag out the widget component, the drag out of that and search for "get user widget object" (i think is what it is called), and then you cast that widget object to your widget class that has all this NPC stuff in it. Once you have that, you will be able to easily pass along info from the NPC to the widget it contains and set those variables and texts.
answered Feb 19 '19 at 07:35 PM
Nebula Games Inc
Follow this question
Once you sign in you will be able to subscribe for any updates here