Controlling behavior through UMG
In this part of the chapter, we want to touch on using UMG to control the behaviors influenced upon our agents. We will do this by first creating a UMG widget with the proper controls to manipulate our three float variables. Then, we must assign this user widget to the owning PlayerController. Then, we will end by adding a function that will reset the Agents to their original position, starting the simulation fresh.
A simple UI
Let's navigate to our Content Browser, create a new Widget blueprint, and name it FlockingUI
. Let's open this up and go to the Designer tab to get started, as follows:
Let's drag Vertical Box into our Hierarchy panel.
Next, set the slot (Canvas Panel) properties: the Size X value to 350.0 and the Size Y value to 600.0.
Then, drag a button into our Hierarchy class under Vertical Box. Rename the button ResetButton. Next, set the Vertical Box slot's Padding properties to 75.0 and 25.0.
Lastly, drag Text into our Hierarchy class under ResetButton...