# Creating a Basic Toggle

<span style="font-weight: 400;">To preface, you’re expected to have a somewhat decent knowledge of Unity terminology and how to do basic things. Basically, if you know how to make an avatar and upload it, you should be good.</span>

# <span style="font-weight: 400;">Step 1: Have whatever you want to be toggled ready!</span>

<span style="font-weight: 400;">Shirt, sword, prop, whatever it might be. Make sure you have it all set up already, depending on if you want it on or off by default make sure it’s disabled/enabled in your Hierarchy.  
</span>

[![image-1645290570102.png](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/scaled-1680-/image-1645290570102.png)](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/image-1645290570102.png)

<span style="font-weight: 400;">For example, I’m making a toggle for a sword on my avatar, I have it off by default.</span>

*<span style="font-weight: 400;">(Normally I would be using a parent constraint instead but thats a completely different tutorial.)</span>*

# <span style="font-weight: 400;">Step 2: Duplicate your avatar</span>

<span style="font-weight: 400;">This will make it the easiest to avoid accidentally doing anything destructive to your avatar, do this whenever you make a new animation for your avatar, just make sure you have everything you’ll need already set up before doing this. The shortcut for duplicating something is </span>**ctrl+d** <span style="font-weight: 400;">while you have it selected, or right-click the main parent and click “duplicate”.</span>

# <span style="font-weight: 400;">Step 2.5: Actually making the toggle animation</span>

<span style="font-weight: 400;">With the duplicated version of your avatar selected, go to the “Animation” window, and click the “Create” button, then click the small red circle to “record” any changes you make, the timeline bar should turn red. Now, activate/deactivate whatever you’re toggling in your Hierarchy and a new keyframe should be made in your Animation window. </span>

<p class="callout info">*<span style="font-weight: 400;">If you cannot find your animation window, press ctrl+6.</span>*</p>

[![image-1645290732394.png](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/scaled-1680-/image-1645290732394.png)](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/image-1645290732394.png)

<span style="font-weight: 400;">Since I’m making an animation to toggle the sword *on*, I have the “Is Active” checked. You'll also want to create a toggle off animation, click the name of your animation in the window and create a new one doing the same steps, but make sure "Is Active" is off.</span>

# <span style="font-weight: 400;">Step 3: Set up your expression menus and parameter file</span>

<p class="callout info"><span style="text-decoration: underline;">*<span style="font-weight: 400;">If you already have these files on your avatar you don’t need to do this.</span>*</span></p>

## <span style="font-weight: 400;">Create the files</span>

<span style="font-weight: 400;">Right-click in the empty space of your “Project” window and go to Create&gt;VRChat&gt;Avatars and make an Expression Parameters file and an Expressions Menu file. Also, create an Animation Controller under the Create tab as well.</span>

[![image-1645290962385.png](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/scaled-1680-/image-1645290962385.png)](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/image-1645290962385.png)

[![image-1645290974407.png](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/scaled-1680-/image-1645290974407.png)](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/image-1645290974407.png)

### <span style="font-weight: 400;">Put them in your descriptor</span>

<span style="font-weight: 400;">On your avatar, go to the Avatar Descriptor Component and find “Expressions” then click “Customize” then put the files you just made into their respective slots. </span>

<p class="callout info">*<span style="font-weight: 400;">(Again, if you already have these attached to your avatar you don’t need to do this.)</span>*</p>

[![image-1645291076500.png](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/scaled-1680-/image-1645291076500.png)](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/image-1645291076500.png)

<span style="font-weight: 400;">Under “Playable Layers” click customize if it hasn't been clicked already, and put the Animator Controller you made into the “FX” slot.</span>

<p class="callout info">*<span style="font-weight: 400;">(Again, if you already have this attached to your avatar you don’t need to do this.)</span>*</p>

[![image-1645291121930.png](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/scaled-1680-/image-1645291121930.png)](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/image-1645291121930.png)

### <span style="font-weight: 400;">Create a new parameter</span>

<span style="font-weight: 400;">In your Parameter file, click “Add” and change the type to “Bool”, you can set the name to whatever you want.  </span><span style="font-weight: 400;">I prefer to turn off “Saved” for props like this.</span>

<p class="callout info">*<span style="font-weight: 400;">(A parameter with “Saved” enable will store the value of that parameter in-game when you switch off the avatar. So if you have “Saved” on, when you switch off the avatar with your toggle still on, it’ll save when you switch back into it and vice versa.)</span>*</p>

[![image-1645291181391.png](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/scaled-1680-/image-1645291181391.png)](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/image-1645291181391.png)

### <span style="font-weight: 400;">Create a new menu control</span>

<span style="font-weight: 400;">In your menu file, click “Add Control”, name it whatever you like, turn the “Type” to “Toggle” and change the “Parameter” to the Bool parameter you made.</span>

*<span style="font-weight: 400;">(The icon be whatever you want, it’s optional)</span>*

[![image-1645291240989.png](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/scaled-1680-/image-1645291240989.png)](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/image-1645291240989.png)

# <span style="font-weight: 400;">Step 4: Making the actual toggle</span>

### <span style="font-weight: 400;">Create a new layer</span>

<span style="font-weight: 400;">Select your Animator Controller file, open your “Animator” window, and create a new layer by clicking the ‘</span>**+**<span style="font-weight: 400;">’ button, name this layer whatever you want. Click the little cog on the layer and change “Weight” to “1”, if you do not do this, it will not work, period.</span>

### [![image-1645291327989.png](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/scaled-1680-/image-1645291327989.png)](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/image-1645291327989.png)

### Add your parameter

<span style="font-weight: 400;">Go to the “Parameters” tab and click the ‘</span>**+**<span style="font-weight: 400;">’ button, then add a new “Bool” parameter. [<span style="text-decoration: underline;">***Make 100% sure it is named the same exact thing as it is in your parameter file from earlier or it will NOT work.***</span>](#bkmrk-make-a-new-parameter)</span>

[![image-1645291428587.png](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/scaled-1680-/image-1645291428587.png)](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/image-1645291428587.png)

### Drag in your animations

Drag both the animations you just made into your animator in the layer we just made. Since my toggle is going to be off by default I'm making my "Toggle Off" animation the default state(orange node), you can right click an animation to change which is the default state. Your other toggle animation will be gray.

[![image-1645291655457.png](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/scaled-1680-/image-1645291655457.png)](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/image-1645291655457.png)

## <span style="font-weight: 400;">Turn off ‘Write Defaults’ for both nodes</span>

<span style="font-weight: 400;">[VRChat documentation tells you to do this](https://docs.vrchat.com/docs/avatars-30#write-defaults-on-states), do it.</span>

<span style="font-weight: 400;">“Turning Write Defaults </span>**off** <span style="font-weight: 400;">makes any changes made to the avatar through animation clips carry over to the next animation, for example if you set something ‘active’, it won't deactivate when transitioning off that state. When Write Defaults is </span>**on**<span style="font-weight: 400;">, it </span>*<span style="font-weight: 400;">will </span>*<span style="font-weight: 400;">revert any changes made to the avatar, so if you set something "active", instead of retaining, it will deactivate when transitioning to another state. VRChat recommends you uncheck Write Defaults because of bugs with stations iirc.”</span>

<span style="font-weight: 400;">(Explanation given by </span>[<span style="font-weight: 400;">Marino</span>](https://twitter.com/marinodev?s=21)<span style="font-weight: 400;">)</span>

<span style="font-weight: 400;">Uncheck ‘Write Defaults’ for both gray and orange nodes by selecting each respectively and unchecking it in the inspector.</span>

[![image-1645291809806.png](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/scaled-1680-/image-1645291809806.png)](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/image-1645291809806.png)

<p class="callout info">***Note:*** *<span style="font-weight: 400;">don’t mix write default settings, if another layer on your animator has write defaults on and another has write defaults off it can cause problems, due to the way we’re setting this up in the tutorial, you can skip this step and leave write defaults on, but it's </span>****highly recommended*** *<span style="font-weight: 400;">that you turn write defaults off if you can.</span>*</p>

### *<span style="font-weight: 400;">Add transitions</span>*

<span style="font-weight: 400;">Right-click your orange state and click “Make transition”, click your gray node. Then do the same with the gray node to the orange node. It should look sort of like this.</span>

[![image-1645291938629.png](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/scaled-1680-/image-1645291938629.png)](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/image-1645291938629.png)

### <span style="font-weight: 400;">Change transition settings</span>

<span style="font-weight: 400;">Click the transition with the **arrow pointing towards your toggle on** state it should turn blue, and in the Inspector uncheck “Has Exit Time” and set “Transition Duration (s)” to 0</span>

[![image-1645292000935.png](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/scaled-1680-/image-1645292000935.png)](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/image-1645292000935.png)

<span style="font-weight: 400;">In the same transition, scroll down in the inspector window and click the ‘</span>**+**<span style="font-weight: 400;">’ button on “Conditions”, make sure it “</span>*<span style="font-weight: 400;">\[Parameter Name\] true”</span>*

[![image-1645292015015.png](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/scaled-1680-/image-1645292015015.png)](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/image-1645292015015.png)

## <span style="font-weight: 400;">Repeat for other transition</span>

<span style="font-weight: 400;">Now select the arrow pointing </span>**away**<span style="font-weight: 400;"> from your toggle on and do the same steps but make sure it’s “</span>*<span style="font-weight: 400;">\[Parameter Name\] </span>****false****<span style="font-weight: 400;">” </span>*<span style="font-weight: 400;">instead.</span>

[![image-1645292113693.png](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/scaled-1680-/image-1645292113693.png)](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/image-1645292113693.png)

# <span style="font-weight: 400;">Step 5: All Done!</span>

<span style="font-weight: 400;">You can now upload your avatar to VRChat and your toggle should work! These toggles can be applied to pretty much anything if you just follow the same logic. Get to making those toggles!</span>

<span style="font-weight: 400;">If you encounter any issues or need help please direct all rage to </span>[<span style="font-weight: 400;">@TrixxedHeART</span>](https://twitter.com/TrixxedHeART)<span style="font-weight: 400;"> </span>*<span style="font-weight: 400;">(That’s a joke please be nice to me or I’ll be sad)</span>*

<span style="font-weight: 400;">(In the gif below I’m using [Lyuma’s Avatar 3.0 Emulator](https://github.com/lyuma/Av3Emulator) to test the toggle in-Unity)</span>

[![image-1645292150647.gif](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/image-1645292150647.gif)](https://vrclibrary.com/wiki/uploads/images/gallery/2022-02/image-1645292150647.gif)