RUST: Creating Proximity Doors Last edited 1 year ago2022-09-29 07:52:43 UTC

How do I create a proximity door ?

(i.e. a door that stays open as long as the player remains in a certain area near the door)

You've most likely seen the doors in the Half-Life single-player campaign that opened only as long as you turned a wheel, but which started to close after you let go of the wheel. Remember the underwater grates in "Surface Tension"? Those are the type of doors I am referring to. They are momentary_door entities, and the controlling wheel is a momentary_rot_button entity.

The momentary_rot_button entity, though, has an interesting property. Repeatedly triggering the entity has the exact same effect as if you hold down the +use key while standing near it! We will use this property to activate our proximity door.

Creating a proximity door requires the use of three entities: We will discuss each entity in turn.

Step 1: Creating the momentary_door entity

If you are in any way familiar with creating normal func_door entities, then this will be easy for you to understand. Create your door in the usual way, except that instead of making it a func_door, make it into a momentary_door. Set the door's angle, speed, lip, etc., to the values you want.

Now we need to give the door a name, so that we can use a momentary_rot_button to activate it. The example map uses the name proxim_door.

Finally, we want the momentary_door to close automatically once we stop triggering the momentary_rot_button. To do this, set the door's spawnflags value to 32. (In Worldcraft, this means to check only the "Toggle" spawnflag). Enabling this spawnflag allows the door to close automatically once the momentary_rot_button stops activating it.
Screen shot of the momentary_door in WorldcraftScreen shot of the momentary_door in Worldcraft

Step 2: Creating the momentary_rot_button entity.

If you've created a func_rot_button entity before, then this will be easy, too. Create your rotating button as usual (complete with origin brush!), but turn it instead into a momentary_rot_button entity. Set its speed, auto-return speed (returnspeed), and rotation distance (distance) as desired.

For this tutorial, since the player doesn't have to + use the button to activate it, the button does not have to be set up in a visible part of the level. Since the momentary_rot_button entity is brush-based, it can even be placed in the "void" outside of the map. The example map places the button in full view of the player so that you can see that the button turns when triggered repeatedly.

Now, set the target key (WC: "Targetted object") to the name of your momentary_door. The example map sets it to proxim_door. This allows the button to open and shut the door.

Now, set the spawnflags of the momentary_rot_button. The base value that you need to enter in the spawnflags key is 18. (In WC, this is equivalent to checking only the "Not useable" and "Auto Return" spawnflags). Enabling Auto Return allows the door to close itself automatically once the button is no longer being activated. Add 64 to this value (WC: check "X Axis") if the button rotates around the X-axis, or 128 to this value (WC: check "Y Axis") if the button rotates around the Y-axis.

Finally, give the button a name, so that we can activate it via triggers. The example map uses the name proxim_btn.
Screen shot of the momentary_rot_button in WorldcraftScreen shot of the momentary_rot_button in Worldcraft

Step 3: Creating the trigger_multiple entity.

This is the most straightforward step, provided that you have created triggers before. Create a brush to define your proximity area and cover it in the AAATRIGGER texture. Then select it and turn it into a trigger_multiple entity.

Set the trigger's target key (WC: "Target") to the name of the momentary_rot_button. (For the example map, this is proxim_btn.)

Then set the trigger's delay key (WC: "Delay before reset") to 0.1. This causes the trigger to fire every tenth of a second while the player remains in the trigger area [unless you enable the "No Clients" (2) spawnflag -- see below]. Since the trigger targets the button, which in turn controls the door, the door will open and stay open as long as the player remains in the trigger area.

The different spawnflags of the trigger_multiple allow you to customize which beings in the map get to use the proximity door:
Screen shot of the trigger_multiple in WorldcraftScreen shot of the trigger_multiple in Worldcraft

Step 4: Compile and run.

Compile and run your map. The door should begin to open when the player steps into the trigger area, and should stay open as long as he/she stays in the trigger area.

I've created a small example map that illustrates the concept. The first door you come to is a normal sliding func_door -- ignore this one. The second door is the proximity door. There is a wheel along the wall here -- this is the momentary_rot_button that controls the door. I decided not to hide it so that you can see the button rotate when it is triggered, and to allow you to +use the wheel yourself to open the door. The proximity area for the door is the area covered in the red and white stripes.
User posted image
User posted image
NOTE: Special thanks to [RPS]Odd Sock, who came up with the basic mechanism for creating such a door, at least as far as I know.
This article was originally published on Gamedesign.net RUST.
The original URL of the article was http://www.gamedesign.net/node/6.
The archived page is available here.
TWHL only publishes archived articles from defunct websites, or with permission. For more information on TWHL's archiving efforts, please visit the TWHL Archiving Project page.

Comments

You must log in to post a comment. You can login or register a new account.