
Creating Custom Triggers in Unreal 4 Blueprints: Part 1
Scripting levels is fun, but having control over your triggers can be a pain. In this tutorial I’ll show you how to create your own custom triggers with Blueprints!
It makes levels easier to script when you can customize the shape of your triggers, so that’s what I’ll be covering in Part 1 of this tutorial!
Check Hidden in Game under the Rendering tabs in both the cube mesh and the billboard to hide them while playing your levels.
Go ahead and name the new enum “Trigger Mesh Type.” This will control which mesh is currently being used for collision by the trigger.
Now we need to add that enum to our blueprint. Create a new variable in the trigger blueprint and set the variable type to TriggerMeshType in the Details panel. Name it “Mesh Shape,” and click the eye icon to make the variable public to the level editor. For all the future variables you create, it’s a good idea to put them into categories for easy access an organization. I created a new category called “TriggerSettings.”
Here is where we start getting to the good stuff! In the Construction Script, drag out a reference to the new Mesh Shape enum variable and connect it to a Switch. Use the Switch that contains the values we added earlier. Then drag out a reference to the Cube mesh component… mine is called Trigger Mesh. From here you need to add 3 copies of the Set Static Mesh node. Connect everything just as in the image below. For the New Mesh slot, find a mesh that fits with the Switch options… Box, Sphere, Cylinder.
Stay tuned for Part 2 where I’ll cover how to setup the trigger events!