Language:
Page Info
Skill Level:
Engine Version:

4 - TV Blueprint Setup - Construction Script

Choose your OS:

With the Components of our TV Blueprint defined, we'll set up the Construction Script so that we can change the content on our TVs when we place them in our level.

Steps

  1. Inside the TV_Blueprint, click on the Construction Script tab below the Main Toolbar.

    Construct_01.png

  2. Right-click in the graph and add a Create Dynamic Material Instance node. Set the Parent to M_TV_Inst and connect as shown.

    Construct_02.png

    To change the Media Texture within the Material applied to our TV, we first need to create a Dynamic Material Instance based on that Material and assign it to our TV.

  3. On the Return Value of the Create Dynamic Material Instance node, right-click and select Promote to Variable and call it TV_MID.

    Construct_03.png

    This will store a reference to the Dynamic Material we created, which we can use later in our setup.

  4. In the Components window, select the TV_Mesh, then, in the graph, right-click and choose Set Material (TV_Mesh).

    Construct_04.png

    This will add a reference to the TV and a Set Material node, which we can then assign our Dynamic Material to.

  5. From the My Blueprint panel, drag the TV_MID variable onto the Material pin of the Set Material node and connect as shown.

    Construct_05.png

  6. Drag off the TV_MID node and use a Set Texture Parameter Value node. Connect as shown.

    Construct_06.png

  7. Set the Parameter Name to TV_Texture, then right-click on Value. Select Promote to Variable and call it Texture for TV.

    Construct_07.png

    This will enable us to define what Media Texture we want to sample on a per-TV basis, as it is now a variable.

  8. From the Components window, drag the Media Sound asset into the graph, then drag off it and use Set Media Player.

    Construct_08.png

  9. Right-click on the Media Player pin and select Promote to Variable. Call the new variable Media Player for Sound and connect as shown.

    Construct_09.png

    Similar to the way we set up our texture, this will enable us to define what Media Player to associate the Media Sound with on a per-TV basis.

    Your full graph should look like the following.:

    Click for full view.

  10. In the My Blueprint panel, select the TextureForTV variable, then set as Instance Editable and assign the MediaPlayer_01_Video Media Texture.

    Construct_11.png

    Here, we are defining the Default Value to use for our Texture and enabling Instance Editable gives us a way to change this value for each instance of this Blueprint.

    In order to set the Media Texture Default Value, you may need to click the Compile button from the Main Toolbar.

  11. In the My Blueprint panel, select the MediaPlayerForSound variable, then set as Instance Editable and assign the MediaPlayer_01 Media Player.

    Construct_12.png

    Similar to the previous step, we are assigning the Default Value and providing a way for us to change this value on a per-instance basis.

    In order to set the Media Player Default Value, you may need to click the Compile button from the Main Toolbar.

End Result

Our TV Blueprint is now set up in a way that enables us to define what Media Sound, Media Texture, and in the next step, Media Player Assets we want to associate with which TVs we place in our level. By creating variables for those Assets and making them Instance Editable, this gives us the flexibility to change the content on any TV we place, but reuse the functionality that enables the player to turn the TV on or off.