Passing a Blueprint Instance

I’m working on my first Unreal title and running into an issue that I can seem to figure out. I’m converting an old 2D project into Unreal, and the first thing I’m tackling is the conversation system. I’ve got the bones of it in and working, but I’ve hit a bit of a wall. I’ve created a new class Conversation that extends Actor. This conversation object contains all the information for a particular conversation the player can have with an NPC. It handles what information is put on the buttons of the conversation UI, and what each button should do when clicked, etc. I’ve created a blueprint TestConversation, that is based of that Conversation class. I want to be able to build all the various conversations as blueprints in the editor, and pass the current conversation object to the conversation hud when it is displayed. I have a method in my conversation hud to set the current conversation, but what I can’t figure out is how to pass a specific conversation blueprint to that method.

Currently I just have the C key bound to toggle the display of the conversation GUI on and off. That code is handled in the player controller blueprint at this point in time. In the actual game, the player will click on an NPC they can talk to, and that will bring up the conversation GUI, but I’m not at that point yet. So for now, I just want to load up this TestConversation blueprint instance into the hud when I display it, but I haven’t been able to figure out how to access it from within my PlayerController blueprint. I’ve tried creating a variable in the player controller, but don’t know how to set the value of that variable to the TestConversation.

Any help would be appreciated.

Eric

If you are trying to pass the name of a blueprint class, then create a variable in the player controller. The variable should be of type ‘class_<followed by the class of your conversation blueprint>’ (eg: ‘class_TestConversation’. However if you want to use an instance of your bcoversation BP, the variable’s type should be ‘object_TestConversation_C’. I assume you know the difference between class and object. If you go with the class name route, you can assign the value from the default properties section (or wthin the blueprint based on some logic). Later in your HUD, you will need to make an instance of this class to actually use it. If you go with the object route, you first need to make an instance of TestConversation somewhere and assign it to the variable (using SET node). But in this case, you can use it directly inside the HUD without instatiating it again.

Yea, I created a variable in my player controller of type TestConversion from under the heading of Object Reference. I had read in the documentation about finding the one with the _C, but there is are none with the _C, so I’m guessing that was changed? I’m using 4.5.1. The problem I’m running into is setting that variable. The variable is in the PlayerController, but I don’t know how to get a reference to the TestConversation that has been added to the level from within the PlayerController blueprint. In the documentation I’ve read, it said to set it in the default details section of the editor, but there is no is instance of PlayerController in the scene outliner for me to select and set the value, and I couldn’t find a function I could use in the PlayerController blueprint for it to get the TestConversation instance that is in the level. Should I drag an instance of the PlayerController into the level? I didn’t think that was how that blueprint worked.

Doing this in C++, I would create an instance of Conversation, set the values and pass it in. I’m just being super dense on how to do the same thing in blueprints. I know I’m going to feel super stupid once I have it figured out, but right now I’m blind as to what I’m doing wrong. :slight_smile:

Let me know if screen shots of the blueprints I have would be of any help. Maybe I just have this totally setup wrong. As I said before, I’m still kind of in the mode of just getting some of these various pieces working and getting a better understanding of blueprints and how they interact with the C++ side of things.

Thanks,
Eric

OK, I got it working. I moved the stuff that I had in the player controller into the level blueprint. I then added an object to the level and added a variable to hold a conversation along with a method to get the stored conversation. I then added a click event to that object in the level where I get the conversation stored in it and pass it along to the GUI. This matches what the actual game functionality will be once we have NPCs in.

Eric