Open doors automatically

A player asked me yesterday the code for a trigger to open doors automatically. I referred him to the forum to post his question. He is not a native English speaker and may bot have been comfortable posting his question. So I decided to post the question and answer for him. If anyone has any questions or comments, feel free to reply.

Below is the code to open a door with a trigger. There are scripts that automatically open every door as a player approaches, but this trigger is for specific doors. Similar triggers can be used to raise and lower bar gates as the player approaches/leaves the gate.

What the trigger is doing is playing the open or close animation based on conditions. You can get more complex with the conditions and only open the doors when a specific item is in the player’s inventory.

To open a door we will be using animate. animate takes the follow parameters:
objectName: Object
[animationName, phase, speed]: Array
animationName: String - name of the animation. This is the class-name of the animation defined in the config.
phase: Number - range 0 (start point of the animation) to 1 (end point of the animation). The speed, in which the animation is processed, is defined in the addon’s config.cpp and cannot be changed during running missions.
speed: Boolean or Number - When true animation is instant. Since Arma 3 v1.65.138459 Number > 0 is treated as config speed value multiplier

For most standard doors on building you have placed in the editor:

Assign a variable name to the building (this is the name we will use for the Object parameter). In this example we will be naming the building ‘myBuilding’.

In the editor you can open the building settings and view Object:Special State to find out how many doors are in the building. Most door animations are named ‘Door_X_rot’ where X is the door number. In this example the front door of the building is door #3.

In the majority of buildings the doors are numbers consecutively starting with 1. In the Object:Special State section, if you change any of the door states,to open for example, all doors in the building will then be labeled with the door number in the editor. If you do not see the door labels zoom in a little.
arma3_x64_Kb13qj2SVD.png


There are other door animations so if Door_X_rot dose not work (it will work in a majority of cases), you may have to open the building config to get the animation names. The animations for the small sliding doors in the Apex domes, for example, are named ‘Door_1A_Move’ and ‘Door_1B_Move’.

Create a trigger covering both sides of the door (if you wish)
Type: None
Activation : BLUFOR (Or any option you wish i.e. Any Player)
Activation Type: Present
Repeatable: Checked
Servery Only: Unchecked

Condition: this
On Activativation:
myBuilding animate [“Door_3_rot”, 1]
On Deactivation:
myBuilding animate [“Door_3_rot”, 0]

If the door you want to open and close is in a building that is a map object, meaning one that you did not place, you will not be able to set the variable directly, need to set the variable of the Object using something like ‘nearestBuilding’.

I hope this helps. If you have followup questions let me know.