Post tutorial RSS How to toggle entities without toggle input

This tutorial shows you how to create a button that can toggle entities which have no toggle input.

Posted by on - Advanced Mapping/Technical

This tutorial shows you how to create a button that can toggle entities which have no toggle input. Note that this tutorial is for advanced users and I presume you understand Source's Input/Output system.

1. The Setup
Image you want to create a light switch. You set up a func_button, a light, a lamp prop model (func_dynamic) and an env_sprite. In the func_button's output you target the light and env_sprite to Toggle on pressed.

2. The Problem
The lamp prop you're using has a lit texture skin, which looks strange when the light is turned off. Luckily the lamp has a dark skin version, so you can simply toggle the skin when the button is pressed. Here is where the problem lies. The prop_dynamic has no "ToggleSkin" input. It can only set a skin by using the "Skin" input which then requires the number of the skin you want to use. To make it worse, the func_button has no "OnPressedOn" and "OnPressedOff" outputs which could help you determine which skin to show. You're going to need a work-around.

3. The Workaround
Change the func_button to a func_brush or func_detail, turning it into a dummy. Now create a small thin block (1 unit) in front of the button with the NODRAW texture on it and make it a func_door. Because of the NODRAW texture, it'll be invisible in game. Set the following properties for this func_door:

Speed: 99999
Delay before reset: 0.1
Check Flags: Toggle / Use Opens / Door Silent

Now you can use the "OnOpen" and "OnClose" outputs to set the skins of the lamp prop. If the light is on initially, make sure you use "OnOpen" to turn everything off and "OnClose" to turn everything back on. This could be the setup.

OnOpen - lamp - Skin 1 (if 1 is the dark skin)
OnOpen - light - TurnOff
OnOpen - sprite - HideSprite
OnClose - lamp - Skin 0 (if 0 is the lit skin)
OnClose - light - TurnOn
OnClose - sprite - ShowSprite

4. Final Notes
By using invisible func_doors you can pretty much toggle every entity input, which the func_button can't. Before I wrote this article, I used the "OnIn" and "OnOut" outputs of the func_button to make toggling work. "OnIn" and "OnOut" refer to the movement of the func_button, but when the button was set not to move, it worked as an On/Off output. It stopped worked out of a sudden, so I guess an update fixed the bug I was exploiting or another bug slipped in. This is another reason why I would advice you to use the func_door trick, so you can make sure your sequences won't break because of a future update.

Comments
Jokerme
Jokerme

Nice one. This is why Source needs some improvements. func_door works better as a button than func_button. This shouldn't happen.

Reply Good karma Bad karma+1 vote
zonbie
zonbie

as long as my level works the way i want it to, i dont care if i have to use func_marshmallow parented to a env_fartcloud. adapt and overcome :)

Reply Good karma Bad karma+4 votes
Jeek
Jeek

Haha, nicely said.

Reply Good karma Bad karma+1 vote
SPY-maps
SPY-maps

funny, i just came around the same issue last night and i too fixed it the way you did.
personally i use the func_door for nearly everything, you can parent stuff to it to let things move, and the in/outputs give much options.
good tut, but for the advanced mapper as you said!

succes
leon

Reply Good karma Bad karma+1 vote
Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.