Jump to content
RicardoLew

Help with a script to open a door when the player is near it!

Recommended Posts

Im still new to the scripting of Arma 3, and im trying to make a simple script where the player get near a house door and it opens.

I got this so far: if (position player isEqualTo [house,[2.5,-1.5,0]]) then {house animate ["door_1_rot",1]};

I dont know how to handle a position with the vector of the house where the door is located, maybe someone can help me with this?

Share this post


Link to post
Share on other sites
9 hours ago, RicardoLew said:

Im still new to the scripting of Arma 3, and im trying to make a simple script where the player get near a house door and it opens.

I got this so far: if (position player isEqualTo [house,[2.5,-1.5,0]]) then {house animate ["door_1_rot",1]};

I dont know how to handle a position with the vector of the house where the door is located, maybe someone can help me with this?

 

I assume house is a single specific building as you are using a global variable. So why don't you place a trigger repeatable player present with

 house animate ["door_1_rot",1] in activation field and house animate ["door_1_rot",0] in deact field ?

 

Note: The relative position from an object is given by commands like modelToWorld or worldToModel, depending on final aim.

Never compare two positions with isEqualTo (there is more chance to win a lottery). Use distance range instead. player distance house < 15m (be careful you player with the center of each model).

 

Share this post


Link to post
Share on other sites

If you need a script for any door of any house, it's different, of course.

 

test this one:

 

0 = [] spawn {  
  while {true} do {  
    _houses = nearestObjects [player, ["house"], 50];  
    if (count _houses > 0) then {  
      _house = _houses select 0;  
      private _intersects = [];  
      {  
        _intersects = ([cursorObject, _x] intersect [ASLToATL eyepos player, (screentoworld [0.5,0.5])]);   
        if (count (_intersects select 0) > 0) exitwith {  
          _intersects  
        }   
      } forEach  ["FIRE","GEOM","VIEW"];
      if (count _intersects > 0) then {  
      _intersect = _intersects select 0 select 0;
      _dist = _intersects select 0 select 1;  
      _is_door = [false,true] select (["door",_intersect] call BIS_fnc_inString);  
        if (_is_door && _dist < 4) then {  
          _select_door = format ["%1_rot", _intersect];   
          _house animate [_select_door, 1,false];
           [_house,_select_door] spawn {
            params ["_house","_select_door"];
            if (_house animationPhase _select_door >0) then {
              sleep 5;  
              _house animate [_select_door, 0,false];
            };
          };
        };  
      };  
    };  
    sleep 0.5;   
  };  
};

 

Sorry I haven't added specific lines for Altis terminal gates. They suck with weird name not compliant with their animation. Same for some Kavala office buildings with glass doors, detected as glass instead of door. Boring!

  • Like 2

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×