Jump to content
Sign in to follow this  
TrueCruel

Break switchMove upon death

Recommended Posts

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 by TrueCruel

Share this post


Link to post
Share on other sites

Don't know but is this right

_y if (!alive _unit) then{

Share this post


Link to post
Share on other sites

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

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×