idle animation while talking

Started by Cerno, Sat 30/01/2016 10:23:40

Previous topic - Next topic

Cerno

Hello all.

I have a flying character and use the Idle animation to make the wings move while the character is standing still in mid-air.

A few problems I have:

  • When the character changes from idle to moving, the animation starts from the beginning which causes a jerk in the animation. What is the best way to synchronise this? I assume there is a way to get the current animation frame and set it for the next view, but how can I get the information that the view changed?
  • If the character talks in mid-air, do I really need to draw one frame for every combination of wing and mouth animation? I would rather have one cycle of mouth animations and one cycle of wing animations and combine them into one animation in-game. I could define two characters, one with only the body/head and one with the wings and try animating them independently, but I was hoping there was a cleaner way to do it.
123  Currently working on: Sibun - Shadow of the Septemplicon

Cerno

#1
It's been a while since I posted this question and I finally found a nice solution that I just wanted to share in case anyone stumbles over the same issue.

I finally went with splitting off the wings to a separate character, so now I have one character for the body and one for the wings.
The body character now only does the talking motions (mouth movements and arms gestures) while the wings can just go flapping constantly.

Now the next problem was tackling the visible jerk that occurs when AGS goes from the movement cycle to the idle cycle and starts each animation at frame 0 no matter where the other one left off.
It was suggested elsewhere that the two-character solution would best be implemented by having the second character follow the first one using the FollowCharacter function.
From my understanding that does not solve the jerk problem since the wings need to switch from walk cycle to idle cycle as well.

So I wrote this script to allow for smooth flapping. Just took the character for a spin and so far it seems to work really well.
I may extend this to other cases where a character talks and moves his body at the same time (think Stan from Monkey Island)

If there are better ways to go about this, please let me know.

Code: ags
//PARAMETERS START
int DELAY = 10;  //wing animation delay
int LOOP_LENGTH = 5;  //number of frames in the wing animation loop
//PARAMETERS END

int offset = 0;
int timer = 0;
bool following = false;

function repeatedly_execute_always()
{  
  //make sure the wings are always in the same room as the character
  if (cChar.Room != cWings.Room)
  {
    cWings.ChangeRoom(cChar.Room);
  }
  
  //make sure the follow function is only called once (not sure how much overhead this produces when called every frame)
  if (!following)
  {
    cWings.FollowCharacter(cChar, FOLLOW_EXACTLY, 0);
    following = true;
  }
  
  // cycle through the wing animations
  if (timer == 0)
  {
    cWings.Frame = offset;
    offset = (offset + 1) % LOOP_LENGTH;
    timer = DELAY;
  }
  timer -= 1;
  
  //make sure the wings always appear in front of the body
  cWings.Baseline = cWings.y + 1;
  
  //copy all character traits to the wings
  cWings.Loop = cChar.Loop; //copy character facing direction (make sure the animation definitions match)
  cWings.ManualScaling = cChar.ManualScaling; (in case the character is scaled manually)
  if (cWings.ManualScaling)
  {
    cWings.Scaling = cChar.Scaling;
  }
  //todo: add more character traits here
}

123  Currently working on: Sibun - Shadow of the Septemplicon

SMF spam blocked by CleanTalk