Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Ciro Durán on Wed 03/09/2003 21:26:38

Title: Animating a character
Post by: Ciro Durán on Wed 03/09/2003 21:26:38
Hello everyone, I'm currently doing a rather complex interaction with a button, after some other commands I run this script:

if (light_fixed == 0 && sound_fixed == 0) {
   PlaySound(0);
   ObjectOn(5);
   Wait(220);
   SetCharacterView(BARNEY, 10);       //This
   AnimateCharacter(BARNEY, 0, 5, 0); //won't
   ReleaseCharacterView(BARNEY);      //animate
   ObjectOff(5);
   PlaySound(10);
   if (conv1_taken == 0) {
     conv1_taken++;
     face_right();
     RunDialog(10);
   }
 }

The game compiles this ok, the problem comes with animating the BARNEY character, it has the view number 10, the view number 10 it has the loop number 0, and when I had animated him with the Interaction editor directly, it worked.

But now, the character is not moving (the rest of the script runs), I've checked everything I can.    Any pointers? am I doing something wrong?
Title: Re:Animating a character
Post by: Scorpiorus on Wed 03/09/2003 21:42:30
The problem is that AnimateCharacter() is a non-blocking function, so AGS doesn't wait for the character to finish animating. It just releases his view immediately. You need to put a wait function just after the AnimateCharacter() or use AnimateCharacterEx() with blocking=1:

...
Wait(220);
SetCharacterView(BARNEY, 10);
AnimateCharacter(BARNEY, 0, 5, 0);
while (character[BARNEY].animating) Wait(1);
ReleaseCharacterView(BARNEY); //animate
ObjectOff(5);
...

or

...
Wait(220);
SetCharacterView(BARNEY, 10); //This
AnimateCharacterEx(BARNEY, 0, 5, 0, 0, 1);
ReleaseCharacterView(BARNEY); //animate
ObjectOff(5);
...

-Cheers
Title: Re:Animating a character
Post by: Ciro Durán on Wed 03/09/2003 21:48:14
Thanks man, there goes another omission from the manual :).