category
General Half-Life 2/Entities
description
Use it to control a door.
keywords
math, counter, 2, math_counter.
To easily understand this tutorial you must know how to create a func_door and a func_button.
OK in this tutorial im going to teach you how to create the affect of a barricade type door with a math counter and some simple output commands. (This is like having a garage door and a remote).
It is basically going to replace setting up path_tracks and all the hassle of lining them up and fixing your door to east or west or whatever you have to do to make your func_traintrack door to look right when you compile your map.
Ok first step let make our door. my func_door just happens to be a metal barricade in front of a window to act as a metal reinforcement.
Now I want to have it so my metal door will go up and uncover my window so I can see outside. But when you work with doors in this fashion they tend to go back down after a few seconds. (This can be prevented in many ways but i'm going to teach you how to do it with a math counter).
Ok when I made my door I made my origin twice as long as my door
That way when it goes up it uncovers just my window and doesn't keep going. Ok now that I have it set to move up i=I go to my flags and I make sure that "Toggle" is the only one checked.
Dont forget do have a name for your door, mine is "glass office barricade door"
- ok your done with your door now.
Now set up your button and math_counter
First setup your math_counter, I named mine "glass office baricade door-counter" (i know really long name) don't change initial value or minimum legal value because it will mess up with the counting process, but
make sure you set MaXimum Leagal Value to 2. Ok now go to your outputs tab make it like this
add- OnHitMax * glass office baricade door * close ---------------
add- OnHitMax * glass office baricade door - Counter * SetValue * 0 ---------------
- ok your done with your math counter now
Now set up your button. I didn't name mine anyting for the simple purpose im not goign to target it with any other entity so i just left that blank.(**side note come back to this**)you can do cool stuff with targeting the button tho, for instanceif you had a breakable object on your door, like a garage system, You could say on heath change disabledoor button and shoot sparks from door with some env_sparks. There are tuns of things you could do with this. - back to the tutorial) ok now go to the outputs tab
make sure you make these.
add- OnPressed * glass office baricade door - counter * add * 1 ------------
add- OnPressed * glass office baricade door * Open -------------------------
Now go to your flags and make sure "Don't move" and "Use Activates" are the only things checked
Ok and your done!!
^^^^----- the breakdown -----^^^^
Ok what i did in this tutorial is have it so the math counters max is set to 2. When the math counter reaches 2 (Maxhit) it will close the door. To do this i set the button to add 1 to the counter every time its pressed, it also opens the door when you press the button but it cannot open twice. So the 2nd time you press the button the open command is canceled out by the counter. on the first press the door opens and it adds 1 , this is the halfway point for the counter. On the second press it adds up too 2 giving the go ahead on the counter to close the door because it has reached its max number. We also have the counter set so when it reaches its max number it will reset itself allowing the process to start over.
And thats how its done
- Generalvivi , if you have any questions or wanna show me an example that you made stop by
http://www.iwannamap.com