weaponsfree 46 Posted November 5, 2015 (edited) For a sniper mission. I've been trying to find a way to loop a breifing animation. I've succeeded, but now it works too well and will keep looping no matter what. I'm using this in init field of the target. anim_ion1 = [] spawn {ion1 switchmove "Acts_B_out2_briefing"; animLoop = ion1 addEventHandler ["AnimDone", { ion1 switchMove "Acts_B_out2_briefing" }]; }; I want the loop to stop when a seperate trigger is fired (when the target unit falls into combat mode), and when the target is killed. To date I've been able to stop the animation with ion1 switchmove "", but the loop kicks in a few seconds later and the target resumes the animation. Even after death. I suspect that I need to build in a killswitch to the loop script itself, but my scripting skills are woefully inadequate despite hours searching for a possible way to kill it. Any help would be most appreciated. Edit : Thanks to moderators for switching this to the correct forum Edited November 5, 2015 by weaponsfree Share this post Link to post Share on other sites
weaponsfree 46 Posted November 7, 2015 After pounding away at it and taking ideas from a few different threads, I found a decent solution. So if anyone searching for a way to create an animation loop that is canceled via trigger, here is my solution Note, I did not use BIS_fnc_ambientAnim because the animations available in that function are not very good. The animation I absolutely wanted was Acts_B_out2_briefing. Which means I had to use switchmove : Add this to a trigger or init : animone = [] spawn {yourunit switchmove "Acts_B_out2_briefing"; animLoop = yourunit addEventHandler ["AnimDone", { yourunit switchMove "Acts_B_out2_briefing" }]; }; This will create an animation loop of the desired animation. To cancel it, in a trigger, use : yourunit removeEventHandler ["AnimDone", 0] Some additional info if you like. In my mission I have a sniper watching over his target with this animation looping. I wanted the animation to stop when the target was shot at (sniper near misses) or when he's killed (since the loop would take over a dead body if you didn't cancel it) So I had 2 triggers to cover the two cases : behaviour yourunit == "COMBAT" and !alive yourunit I have no doubt there is a much more elegant way to do this. But with my limited skills, this is what I found that works. Cheers! Share this post Link to post Share on other sites
Larrow 2823 Posted November 7, 2015 Just incase the EH you have added is not index 0 you can store the index on the unit and retrieve it when you need to remove the event e.g handle = [] spawn { yourunit switchmove "Acts_B_out2_briefing"; animLoop = yourunit addEventHandler ["AnimDone", { yourunit switchMove "Acts_B_out2_briefing" }]; yourunit setVariable [ "animLoop", animLoop ]; };triggercondition behaviour yourunit == "COMBAT" || !alive yourunitOnAct yourunit removeEventHandler [ "AnimDone", yourunit getVariable [ "animLoop", 0 ] ];ORStraight in a unit init with out the need of a trigger handle = this spawn { _this switchMove "Acts_B_out2_briefing"; _animLoop = _this addEventHandler ["AnimDone", compile format[ "%1 switchMove 'Acts_B_out2_briefing'", _this call BIS_fnc_objectVar ]]; waitUntil { behaviour _this == "COMBAT" || !alive _this }; _this removeEventHandler [ "AnimDone", _animLoop ]; }; 1 Share this post Link to post Share on other sites
weaponsfree 46 Posted November 9, 2015 Thanks Larrow for the more elegant solution. I'll clean it up (the all in one code was what I was hoping for in the first place). In case anyone's curious to see the script in action :)https://steamcommunity.com/sharedfiles/filedetails/?id=550636689 Share this post Link to post Share on other sites
jammin1974 0 Posted March 19, 2016 I have been trying to get this to work for nearly a day and for the life of me I'm stumped. The animation just continues after the unit is killed, I think I may of over thought this one too much and have now confused myself. if any one can help I would be so grateful thanks. this is the code Im using in the AI units init field. animtony = [] spawn { tony switchMove "Acts_carFixingWheel"; animloop = tony addEventHandler ["AnimDone", { tony switchMove "Acts_carFixingWheel" }];};​ Share this post Link to post Share on other sites
jammin1974 0 Posted March 21, 2016 I think I'm getting somewhere now . Some of the animations do not react the same i.e. the fixing car animation in the animation viewer will die but the animation continues after death. While the animation used by the OP will not react at all to anything even if a trigger is used with removeEventHandler ["AnimDone", 0] Share this post Link to post Share on other sites
jammin1974 0 Posted March 21, 2016 I think im getting close ive managed to get the animation a: not repeat itself after he has died and b: react after hes been fired upon. Only thing to sort out now is why when shot the AI will go from standing to prone then back to fixing car 7 times then back to fixing car again. Heres what ive got so far animsimon = [] spawn { simon switchMove "Acts_carFixingWheel"; animloop = simon addEventHandler ["AnimDone", { simon switchMove "Acts_carFixingWheel"; {waitUntil {behaviour _this == "combat"}; _this call BIS_fnc_ambientAnim__terminate;} }];}; Share this post Link to post Share on other sites
weaponsfree 46 Posted March 22, 2016 Heya Only thing to sort out now is why when shot the AI will go from standing to prone then back to fixing car 7 times then back to fixing car again. Does this happen when the unit is fired on/goes into combat behavior? Does the unit have a waypoint triggered upon falling into combat? In my mission the character attempts to run away, so I give him a careless / fast move waypoint triggered when he falls in combat behavior. I think that might force the unit to move instead of getting into a mess of animations. Share this post Link to post Share on other sites
jammin1974 0 Posted May 3, 2016 Thanks for reply weaponsfree, The animation Is working fine (it loops fine).The problem is that if you shoot the AI officer in the foot he will exit the animation for a split second ( goes into combat mode, gun up) then immediately trys to go back to the animation, this will happen 7 times then all of a sudden he will just stand up. The best bit is when you actually kill him, he goes into death animation then back to combat stance really quickly. iam not using no triggers just have this code in the init field of the AI officer. Share this post Link to post Share on other sites
weaponsfree 46 Posted May 4, 2016 Well you can always try the clunkier fix I used before larrow suggested his all in one init script. It worked fine on my end. Details are in my second post in this thread.In the init of your character : animone = [] spawn {yourunit switchmove "Acts_B_out2_briefing"; animLoop = yourunit addEventHandler ["AnimDone", { yourunit switchMove "Acts_B_out2_briefing" }]; }; Then in a trigger of your chosing, (I used two different ones that are triggered by death and combat mode), use this in the on activation field : yourunit removeEventHandler ["AnimDone", 0] No idea if this fixes your issue, I can just say I didn't have your behavior when I was using this solution. Share this post Link to post Share on other sites
TacBacon 4 Posted May 4, 2016 I have the same problem too but your solution cant fix my error Share this post Link to post Share on other sites
Jnr4817 215 Posted May 11, 2016 I'm using eden enhanced and am using the hostage feature and animation sitting on ground feature. The hostage is sitting on ground, then once you free him, he gets up, then sits back down again. I need a way to stop the animation, once he is freed. Share this post Link to post Share on other sites
joostsidy 685 Posted May 12, 2016 unit switchMove "" is a rudimentary method of cancelling animations. Might worth a try if other suggestions don't work. Share this post Link to post Share on other sites