Direct control over idle animations

Started by Dave Gilbert, Sun 10/04/2005 21:36:45

Previous topic - Next topic

Dave Gilbert

I recently realized in designing my current game that there are going to be alot of idle animations for the various characters, and the animations depend on various factors - the direction the character is in, what the character is wearing, the mood of the character, etc.  I was wondering if there was a way to have more direct control over the idle animating function, instead of having SetIdleView commands all over the code.  Something like:

OnCharacterIdle(JOE)

{
   if (Joe is wearing jacket)
   {
       if (joe is sad)
           play sad/jacket animation;
       if (joe is happy)
           play happy/jacket animation;
   }
  else if (Joe is wearing tie)
  {
       if (joe is sad)
           play sad/tie animation;
       if (joe is happy)
           play happy/tie animation;
  }
}

You could also set up random idle animations with this function, something AGS isn't capable of now, as far as I can tell.

Is there a way to do this?

edmundito

I think Dave is getting to a point where we might need to formulate a new kind of abstraction for characters. I was talking to him on one of the messengers, and I think that it's  a good time we start thinking about treating characters on ags like actors instead of little robots that move around.

First, I was thinking about having costumes, and each costume has its own set of animations. Each characters could have one or more costumes. Let's say that ben jordan can change his clothes (or has to at some point). Then maybe you have both the old cases 1-3 costumes and the new case 4 costume. Then you can say cBen.ChangeCostume("case1-3"); or something.

Another thing would be to have, for each costume, a list of idle views and blinking animations and such for each ocasion the character is facing (Dave Gilbert's case) For example, the talking animation could have a different range of emotions such as angry, normal, sad,  happy (user-defined, of course) which then you would call character[...].SetEmotion("sad");... something that mades more sense when you read the scripts. This emotion would be set based on the current costume of course, so if say, ben jordan, is wearing the new costume, then the sad animation will be part of the new costume.

Maybe I'm going way too far ahead of time seen as the scripting system changes have not even been officially released yet and I'm proposing to add more stuff to the whole thing. It's just some food for thought, I guess :P

Pumaman

Dave: In the short term, a workaround would be something like this in rep_exec_always:

if ((cEgo.Moving) || (cEgo.Animating)) {
  SetTimer(1, 200);
}

if (IsTimerExpired(1)) {
  // play idle animation
}

that way, the timer is restarted whenever the character is moving or animating, and it will only expire if they have been idle for 5 seconds, at which point you can play the animation.

You and netmonkey raise some good points for the future though, they do need further consideration.

Kweepa

#3
Or using the old scripting...

Set up the character views and loops to be one frame animations of standing still.

In repeatedly execute always, check if the character is in the first frame of the idle view. If so, play a different animation instead.

Code: ags

if (character[EGO].view == IDLE_VIEW
    && character[EGO].frame == 1
    && character[EGO].loop < 4) // this depends on the facing direction
{
  int direction = character[EGO].loop;
  // play what you really want - simple example
  // non-blocking!
  AnimateCharacterEx(EGO, direction+4, 0, 0, 0, 0);
}


[EDIT] Yuck, this won't work for the costumes.
Still waiting for Purity of the Surf II

SMF spam blocked by CleanTalk