mrflay 4 Posted June 13, 2013 Hi, I'm wondering how to properly handle joystick/controller events from within a script. I would like to know when (for example) the player presses the "Forward" button and then handle/override the action with my own custom behavior. This is for a hang gliding mod I'm working on. When the glider is on the ground and the player pushes "Forward", I need to trigger an animation and update the velocity to make it look like the player is carrying the glider. I've got this working reasonably with keyboard input (see below), but I'm not sure how to support joystick or controller input (I don't own either a joystick or a controller). // fn_ground.sqf ... _KeyDownHandlerId = (findDisplay 46) displayAddEventHandler ["KeyDown","_this call FLAY_HangGlider_EH_GroundKeyDown"]; // ev_groundKeyDown.sqf ... _up = actionKeys "MoveForward"; _speedWalk = 2; _speedRun = 6.5; _maxSpeed = _speedWalk; if (_running) then { _maxSpeed = _speedRun; }; if (_key in _up) then { _anim = "AmovPercMwlkSnonWnonDf"; if (_running) then { _anim = "AmovPercMrunSnonWnonDf"; }; if (animationState player != _anim and _speed > 0) then { player playMoveNow _anim; }; _k = 0.2; if (_speed < 1.0) then { _k = 1.0; }; if (_speed > _maxSpeed) then { _k = 0; }; _glider setVelocity [(_v select 0) + _k * (_dir select 0), (_v select 1) + _k * (_dir select 1), (_v select 2) + _k * (_dir select 2)]; _handled=true; }; I'm assuming I should register joystickButton event handler, but how do I know when the button mapped to the "Forward" action is pressed? Share this post Link to post Share on other sites
sakura_chan 9 Posted June 15, 2013 Actually this can be done without scripting. Look at some of the A3 configs to see how vehicle animations are linked to soldier animations. As far as I know, the joystick can only be read from within a display, at least that was the case in A2. I remember a hang gliding addon for OFP ten years ago that animated the guy as he ran haha. Share this post Link to post Share on other sites
mrflay 4 Posted June 16, 2013 Actually this can be done without scripting. Look at some of the A3 configs to see how vehicle animations are linked to soldier animations. I've looked at the configs, but don't really see anything that looks appropriate. Is there anything in particular I should look for? Thanks! Share this post Link to post Share on other sites
xyberviri 1 Posted June 18, 2013 Known issue as of arma 2: https://dev-heaven.net/issues/14934 VBS2 does have the functionality for it though (http://resources.bisimulations.com/wiki/isJoyBtnPressed) Share this post Link to post Share on other sites