Today we'll be talking about blueprint interfaces. Blueprints don't necessarily talk to each other, you have to tell them to do so. So far we've been casting blueprints to each other to get and set variables, but it can be heavy on performance. It's good for experimenting and if you need something quick, but blueprint interfacing is recommended for better performance.
We'll be using our HW7 project that had us practicing animation state machines. We need the animation blueprint and character blueprint to talk with each other.
Inside of ABP_Robo, we've got this in the event graph. Instead of casting to BP_Quinn we're going to make a blueprint interface. Right click on your content browser, blueprints>blueprint interface
 |
This is what it looks like |
First Thing we're going to do is rename the function. Next, some of the variables we want to keep track of are Velocity and isFiring. So we can click on the QuinnData functions and add two variables to the outputs. It's going to store all the data that is transpiring, and then transmit this data to our other blueprints.
 |
Should be looking like this |
Inside of our BP_Quin, we need to get the firing variables into our blueprint interface. First we need to tell BP_Quinn to listen to our BPI. Select class settings up at the top, go into the details tab, and under Interfaces>Implemented Interfaces |
Make sure you hit class settings |
 |
Inside of BP_Quinn
|
Now Quinn Data should show up under interfaces in your my Blueprint tab. |
Inside of BP_Quinn |
Double clicking on it will pop up another window that includes all the nodes from the BPI inside of your BP_Quinn. You can drag variables from the 'my Blueprint' tab into the Quinn Data tab. Velocity is an inherent attribute of a pawn class when it is created, so we just need to call a get velocity node.
Now we need to tell our animation blueprint to listen in to any event associated with BPI Quinn. We do the same thing we did with the BP_Quinn by going into the class settings. Interfaces>Implemented Interfaces. |
Shows up here now |
Now drag off from the 'Try Get Pawn Owner' node and look for Quinn Data. Make sure that it is the one with (Message) next to the name.
You need the one with message because the message node is the one reading the data from the BPI, which we can then set to our other variables. We're completely disconnected the cast node now, but if we compile this, it should work and our character should run and fire. The variables inputted into the BPI sends a signal into the world, The BPI listens to it, and then sends that signal to all of the blueprints we told them to listen to the BPI. The BPI doesn't do anything really, it just holds data and methods, and the other blueprints will set and get the variables from it.
No comments:
Post a Comment