Creating A Visualisation Tool (2/2)
The next stage of this prototype involves the use of Blueprint scripting to add functionality to the tool. The two main features of this tool are:
- Easily visualising multiple design options
- Changing materials of the panels and frame of the structure
To view the different designs, I first had to collect them from the groups>prepare them in 3DS Max>export into UE4. Once I have the pavilions in the correct position with the materials applied, I must convert them to a Blueprint Actor which allows me to use it as a variable in other scripts.
To add functionality to these Widget Interface buttons, I add an ‘OnClicked’ event which triggers the visibility and collision toggle. As shown below, the design reference is the target of these nodes where the ‘OnClicked’ event execution wire is inserted. The red nodes are Boolean's, which execute functions based on questions the script is asking, e.g. pseudo code: ‘if the button is clicked, and the visibility/collision is off, turn the visibility and collision on,’ and vice versa.
To change the material of an object was a much more challenging task for me. This is the basic method and variables that went in to my method of achieving this:
- Create an interface with the sufficient buttons
- Create a Blueprint Interface — this is used to communicate between Blueprint scripts — this will tell the game that the clicked mesh is the ‘Selected Mesh’, this selected mesh reference’s material is then changed.
- Add a ‘LineTraceByChannels’ in the character Blueprint, this sends a line out from the player and checks whether an object was hit or not.
- This line trace is then ‘Casted’ to the design option blueprint, this allows me to get the design as a variable in the character blueprint.
- This variable is then sent into the Blueprint Interface event which tells the game that this object becomes ‘Mesh Selected’ when clicked.
Dominic helped me a lot with getting this to work as well as explaining to me how Blueprint logic works. These skills I learned will definitely be applied in the VR experience scripts when creating an interactive environment.