Missed that part. Booleans are like in c++, anything not 0 or false evaluates to true. To set a variable to false, “myVar = false” or “myVar = 0” and to test for false “!myVar” or “myVar != true” or “myVar == false”
I forgot to mention that the Get Script Interpreter node is apparently causing errors for me. Maybe that’s a hint at why it’s still not working.
When I try to get the the keycount variable via Event Tick inside my Player BP in order to print it out non-stop:
> Error Accessed None ‘CallFunc_GetScriptInterpreter_Interpreter’ from node Get Variable in graph ‘EventGraph’ in blueprint PlayerBP
And as soon as I overlap and “collect” the item (using the node setup from my last post):
> Error Accessed None ‘CallFunc_GetScriptInterpreter_Interpreter’ from node Execute Script in graph ‘EventGraph’ in blueprint KeyItem
Not sure what could be the problem. Maybe the Handler? I simply created a new variable and made it a reference to BPC Dialogue. That seems to be what is shown in the documentation.
(BTW when I put a silenced blank hub in row0 of my data table, the dialogue interface won’t open at all anymore. Maybe I just made some beginner’s mistake because I haven’t studied the sample level enough.)
Sounds like the script interpreter wasn’t set up. Have a look at the video tutorials, the documentation and the sample content on how to get that setup, that should work out nicely
So, there goes my weekend, tinkering with the dialogue system and not getting anywhere. sigh
I started from scratch and migrated the entire dialogue system to my game once more, following the Youtube video, the documentation, and the examples in the demo level very closely. However, I didn’t notice anything different from the way I had set it up the first time. And I am still getting the same error when trying to print out the variable from inside my PlayerBP or when collecting the item. (Printing it from inside the BP ScriptInterpreter right after declaring it works fine of course.)
My PlayerBP:
The script interpreter is spawned in my custom gamemode as is recommended in the video / the demo level:
And here’s something interesting I noticed just now: I’m getting the same errors in your demo level.
- Add an ExecuteScript node (Script String: keycount = 0) to the demo’s BP Script Interpreter right behind its Event BeginPlay (This part doesn’t seem to be the problem.)
- In the Third Person demo character try to get the keycount variable like I did in the picture above
The Result:
Error Accessed None ‘CallFunc_GetScriptInterpreter_Interpreter’ from node Get Variable in graph ‘EventGraph’ in blueprint ThirdPersonCharacter
Something is fundamentally wrong here. Perhaps the declaration of variables has to happen somewhere else?
Or perhaps the Handler variable used with the GetScriptInterpreter node has to be created in a special way?
Hey fookur, I did have a go at testing this in the sample and it was a successful use case, so I’m thinking something in the setup is up, I’m guessing the GetScriptInterpreter function in your BPC_Dialogue is the route problem.
The GetScriptInterpreter node is an interface function, so the custom BPC_Dialogue should override the GetScriptInterpreter function and return the one you’ve spawned form game mode. It should look like this:
That is indeed very likely, because in my GetScriptInterpreter I get this note:
The note didn’t make any sense to me and when I converted this into a pure cast it just went away, so I ignored it.
I have no idea why the cast would fail. The return node that it seems to be asking for is right there, isn’t it?
Edit: I took another look at a completely unaltered version of your Demo Project. When I click “Compile” inside your BPC_Demo_Topic the same blue note appears under the “Cast to BP_SampleDialogueGameMode” node in the GetScriptInterpreter function. However, the demo level appears to be working just fine after that, even though the note says “cast failed”.
Aye, the cast will never fail in the demo, it’s always going to be that game mode type (it should maybe be converted to a pure get or handle the failed return case just to alleviate confusion).
If you are still having problems, make sure to walk through your code with some breakpoints and see what’s happening to your script interpreter instance (eg. is it spawned at the right time, is your game mode cast failing, is the variable null at the time of get).
Yes, I’ve tried using break points already, but they were of no help. Everything seems to work fine, only the variables are not getting through.
I decided to upload you a little demonstration video, because I couldn’t think of anything else to do. Maybe you’ll notice something off.
It’s your own demo level, but the error is the same as in my game.
Thanks for the vid fookur. I believe what’s going on is the way the bpc demo topic was created is as a reference to a component (which is reference to none by default). To create a component, you’d either need to construct one manually (construct object node), or by adding it as a component (using the “Add Component”).
Okay, I added my BPC Dialogue child via “Add Component” to both my ItemBP and my PlayerBP and it works perfectly now. I can breathe again. Thank you very much for your support.
Also, I should probably mention that you were right earlier about variables not working on row 0 of the data table. You HAVE to create an empty first line and silence it. Otherwise the first line of dialogue will always be shown, regardless of the condition. Definitely sounds like something that should be fixed, or at least mentioned somewhere.
Now I can get back to figuring out how to fix that nasty mid-word line breaking. (Yes, I am that guy from Youtube.)
I’m glad it’s resolved and thank you for the confirmation on that bug - I’ve made a note/ticket about it
Haha, I wish you success! The new update isn’t out yet (waiting on Marketplace team), but I’ve exposed some functionality that should make it easier to inherit the UI_TextItems (along with many other fixes/features) if you cared to wait for it.
Hey!
Thanks I figured it out. Great job on updating this by the way!
Is there a way to ask if an NPC is currently inside the player’s UseScanner range of view?
I would like to do this from inside the NPC, and then fire off some nodes to spawn an indicator arrow above the NPC’s head. Just to indicate that they can be talked to. And when the player walks away the arrow disappears.
There is no “OnEnterScannerRange” or “OnLeaveScannerRange” trigger for the NPC to use, right? Then what’s the ideal way to do this?
The way this is done in the demo doesn’t work too well in this case. Because A) I have to also tell the indicator to vanish as soon as the Usable gets out of range, and B) I want to spawn the indicator at the location of a certain dummy anchor component inside the NPC, so it always appears exactly where I want it.
There are two event dispatches you could register to on the UseScanner: NewUsableDetected and UsableLost. I handle this in the player controller or the hud class and then I deal with the ‘usable’ actor in a game specific way from there.
The New Update is now available on the marketplace
NOTE: There is a breaking change in this release. It is minor and quick enough to fix (have a look at the sample dialogue UI and notice the vertical box replaces the previous wrap box)
Glad to hear it, and thanks! (The update is available now btw)
I’m really sorry to say that even though I greatly appreciate your continuous support, I didn’t understand most of that. So after spending two evenings learning about Event Dispatchers (because I had no idea what they were, and I’m still confused about them) I tried to get this to work by myself.
And now this is happening inside my NPC’s blueprint for some reason when I’m trying to bind the indicator spawn event to the dispatcher. I’m sure I’m again just missing something really obvious here due to my lack of experience.
Also, you mentioned that with 1.3 it would become much easier to fix the jumping words issue. Could you maybe elaborate on that?
If I remember correctly I should be able to set the maximum width of the text box somewhere, so the line can foresee where it’s going to end before it happens.
Hi Fookur,
The reason you’re getting that issue is because the signature of the EventDispatcher expects an actor parameter. What you can do to have the engine figure out the signature for you is drag out from the square “Event” node from the dispatcher and find the “Add Custom Event”. This should automatically create the new event for you (which you can rename).
On that topic, the event dispatch only needs to be registered once, so you wouldn’t want to “Bind” on every tick/frame, binding in the begin play might work for you instead.
In v1.3, I’ve exposed the class types in the UI_Dialogue for the text, response, and inline image items. This is helpful because you can create your UI_TextItem derived class and easily tell your UI to use it (in previous version, you would have had to override all of the functions to do the same).
The maximum width deal is more of a UMG issue/decision, you’ll want to create your custom UI_TextItem with the functionality you’re looking for. In your case, you’ll want to make the UI_TextItem aware of it’s final size and force it’s width (probably with a SizeBox) once the item has been initialized.
Ah yes, BeginPlay. That does indeed work. Thank god. Only now when the dialogue ends and the box closes, the indicator does not reappear above the NPC’s head. (Not until he reenters the UseScanner range.) There doesn’t seem to be a dispatcher for that, so is there any other way I can tell the arrow to reappear once the dialogue window has closed? Preferably from inside the NPC’s blueprint so it’s all in one place.
I was happy to see how just clicking the plus button next to the dropdown menu (as seen on your screen shot) creates a child of the original UI_TextItem. That was easy enough. However, from that point on, I was completely lost once again. I tried talking to my NPC and received this error message:
Error Blueprint Runtime Error: Accessed None trying to read property CallFunc_GetTextControl_Control from function: ‘ExecuteUbergraph_UI_Dialogue_TextItem’ from node: SetText (Text) in graph: EventGraph in object: UI_Dialogue_TextItem
Then I realized the UI_TextItem child didn’t even have a text widget, but only an empty canvas. So I added one, but it did nothing for me. I tried a couple more things today, but no, nothing worked. This isn’t as easy as I thought it would be. I hoped that creating a child of UI_TextItem, and throwing its text widget into a SizeBox, and assigning a width to that would do the trick, but there seems to be a lot more to it.
That almost sounds like I also have to change some things in the graph tab…
Yep, you need to go into the graph and override the Getters when inheriting from UI_Dialogue (check out the functions in the demo sample UI on how to do this). Inheriting UMG is sadly not a trivial thing, you need to create the new UI and tell the getters who the widgets are so the rest of the UI functions can know what to affect.