UDK Scripting Series by Pete Bottomley:
Intro to Kismet
How to Pick Up and Place Item
How to Trigger Material Instances
How to Spawn Bots in Kismet - Part 1
How to Add Functionality to the Bot - Part 2
Bot Functionality Final Touches - Part 3
Bools - Puzzle Design and Interaction
Cinematics Introduction Part 1/2
Cinematics Introduction Part 2/2
Using Console Commands as Gameplay Elements
How to Prototype Quick Time Events in Kismet
In this Material Instance tutorial you will learn what a MI is and also how to use it in Kismet.
In this Materials Instance video you'll learn:
- What is a Material Instance
- How to set up a Material to create an instance
- What a Material Instance Actor is
- How to add MI Actor to Matinee along with Material track
More info on MI's can be found here: UDN Instanced Materials
1. We start off by adding a mesh to the scene which has an Emissive channel on it. For this example I have used StaticMesh'LT_Light. SM.Mesh. S_LT_Light_SM_Light01'. Find open the static mesh properties and find which material it uses. Create a copy of this material and put it into your custom folder. For this example I named my material Materials. Mat_Light01.
Open up the material and add a Multiply (M + LMB) and a Constant 1 (1+LMB). Right click on the constant one and Convert it to a parameter. Give it a parameter name such as LightState. Hook up the output of the emissive node to the A of the Multiply. The output of the Constant 1 to B of the Multiply. Hook the output of the multiply directly into the Emissive channel.
click on image to view full size
In your content browser right click on your Mat_Light01 (or whatever you named it) and select Create New Material Instance (Constant). Leave all the settings the same and click ok. Double click on your newly create MaterialInstanceConstant and go to Parameter Groups - Scalar Parameter Values and make sure you tick LightState (or whatever you named your parameter). The default value should be 0. If you change this to 1 the light should come on in your material. Check this and if it doesn't work go back and repeat the previous step. Change the value back to 0 and save your package.
2. To create our second material, right click in an empty space in your custom package in your content browser and select New Material. Create two Constant 1 (1+LMB) and two Constant 3 nodes (3+LMB). Add an IF to your editor by searching in the box to the right of the editor. Hook your materials up like in the Image below. Convert the top constant to a parameter and give it a parameter name. In this example I have named it SwitchState.
click on image to view full size
Like in the previous material instance example, right click on your newly created material and create an instance constant and tick the box that says SwitchState. Also change the value from 0 to 1 and make sure it changes from red to green. Set the value back to 0 and save your package.
3. We need to apply our material instances to our relevant actors in our scene. For the switch I added a plane to the scene (StaticMesh 'dwStaticMeshes. Plane') and added the Mat_Switch_INST to its material properties. I also added the Mat_Light01_INST to the light mesh that I had in my scene.
Next we open up our content browser and go to Actor Classes and in the search box type in MaterialInstanceActor. Select it and drag it into your scene. You will need two for this example. One near your light and one near your switch. Apply the Material Instance to the relevant MaterialInstanceActor in your scene by opening its properties and plugging it in the Mat Inst property field.
Follow the same process for the switch you are toggling. Making sure you apply the material Mat_Switch_INST to the MaterialInstanceActor as well as the plane you added to your scene.
4. Now that the hardest part is out of the way you can add a trigger where the switch is. Alter whatever collision properties you wish to for the trigger and then add it into your Kismet selected a Used Trigger. Right click and create a new Matinee and with the Material Instance Actor closest to the switch selected right click and Create New Empty Group and name it MISwitch. Right click on the group and select Add New Float Material Param Track.
On the track properties change ParamName to SwitchState (or whatever you named it in this example). Make sure your time bar is on 0 and press Enter/Return or click Add Key. Scroll to how many seconds you want the sequence to take (you only need a short sequence such as a second or so) and add a key. Right click on the key and choose Set Value and change it to 1. If you have followed all the previous steps correctly then the switch should go from Red to Green.
Repeat the process for the Light. Select the Material Instance Actor for the light, right click Create New Empty Group. Name the Group MILight. Add another Material Param Track. Change the Param Name to LightState and then add your keys again, setting the second key to a value of 1.
Both materials should work now. The red material should turn green. And the light should go from Off to On. If it is not working, make sure you have saved your package and check the parameter names. Also sure your groups are linked with a MaterialInstanceActor and the MaterialInstanceActor and the StaticMeshes have the correct INST material applied to it.
5. You can then hook up a Used trigger to the player of the Matinee. I unchecked Aim to Interact in this example. I also added a Play Sound node (S+LMB) and chose the sound SoundCue 'A_Interface.menu. UT3MenuCheckboxSelectCue' from the Menu sounds. I also added a Log (L+LMB) and added an Obj comment of Switch On for debugging so that I knew the switch was working.
You can create copies of the MaterialInstantConstant to have multiple variations of the same thing. For example Mat_Light01_INST becomes Mat_Light02_INST this will allow you to have two light platforms you can switch on. Don't use the same MaterialInstance for two things, unless you want them to both trigger together, because once you change the value in Matinee it will apply it to all Actors with that MI assigned to it.
Keep in mind this is a simple Kismet set up but a lot of different things to change. Keep re-doing the tutorial and practicing with other materials such as the lights on the door materials. Make sure you are always checking which materials are applied where and to save your packages.