TrueCruel 10 Posted February 8, 2014 (edited) Hi there! I have a problem with my animation script. It loads up fine, but how to disable switchMove when the unit gets killed (so it uses the standard death animation)? This is how I call it: 0 = [hall, "HubBriefing_talkAround", true] execVM "animation.sqf"; And the animation.sqf itself: _unit = _this select 0; _animation = _this select 1; while {true} do { if (alive _unit) then { _unit switchMove _animation; } else { if (!alive _unit) then{ _unit switchMove ""; }}; }; Buth if I write it that way: _unit = _this select 0; _animation = _this select 1; while {true} do { _x = if (alive _unit) then { _unit switchMove _animation; } else { _y = if (!alive _unit) then{ _unit switchMove ""; }}; }; It shows me an "generic error in expression" scripterror in "_x |#|= if", but then the guy falls down like he should. I hope somebody can help me how to do it right :D Thx in advance! Edit: playMove with disableAI "MOVE" never worked for me... Edited February 8, 2014 by TrueCruel Share this post Link to post Share on other sites
f2k sel 164 Posted February 8, 2014 Don't know but is this right _y if (!alive _unit) then{ Share this post Link to post Share on other sites
TrueCruel 10 Posted February 8, 2014 Ah, this is just a typo here, in my script it's with "=" :D Share this post Link to post Share on other sites
das attorney 857 Posted February 8, 2014 Just put a "killed " EH on him to switchMove "" when it trips: _EHkilledIdx = _unit addEventHandler ["killed", {(_this select 0) switchMove ""}]; http://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Killed If you are working in MP you will need to do some additional syncing-up over the network. Share this post Link to post Share on other sites
TrueCruel 10 Posted February 8, 2014 Thanks! I altered it know it works like a charm: _unit = _this select 0; _animation = _this select 1; while {true} do { _x = if (alive _unit) then { _unit switchMove _animation; } else { _unit addEventHandler ["killed", {_unit switchMove ""}]} }; Eventhandlers are so powerful... xD Share this post Link to post Share on other sites
das attorney 857 Posted February 8, 2014 You only need to add the EH once - from the looks of it, your script will keep adding eventhandlers after the unit dies. Just put it in at the top of the script (before the loop) and then run the anim loop while the unit is alive: _unit addEventHandler ["killed", {(_this select 0) switchMove ""}]; while {alive _unit} do { _unit switchMove _animation; // don't forget to add a sleep!!!!! }; Share this post Link to post Share on other sites