Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: GoToHellDave on Tue 22/01/2013 14:31:40

Title: Animating Characters Through a Series of Views
Post by: GoToHellDave on Tue 22/01/2013 14:31:40
Hi.

I'm having a little trouble animating a particular character through several different views. I'm attempting to have a character do a set series of actions at regular intervals during the game loop using a series of timers. Here is the code:

Code (AGS) Select

function room_AfterFadeIn()
{
  // Create timers for character animations
  cDealer.LockView(9);
  SetTimer(1, Random(400) + 100);
  SetTimer(2, 300);
  SetTimer(3, 400);
  SetTimer(3, 900);
}

function room_RepExec()
{     

        // Animate NPCs
        if(IsTimerExpired(1))
        {
          cDealer.Animate(0, 5, eOnce, eNoBlock, eForwards);
          SetTimer(1, Random(400) + 100);
        }
       
        if(IsTimerExpired(2))
        {
          cBouncer.LockView(2);
          cBouncer.Animate(0, 5, eOnce, eNoBlock, eForwards);
        }
       
        if(IsTimerExpired(3))
        {
          cBouncer.LockView(21);
          cBouncer.Animate(0, 5, eOnce, eNoBlock, eForwards);
          cBouncer.UnlockView();
        }
       
        if(IsTimerExpired(4))
        {
          cBouncer.LockView(2);
          cBouncer.Animate(0, 5, eOnce, eNoBlock, eBackwards);
          SetTimer(2, 300);
          SetTimer(3, 520);
          SetTimer(3, 900);
        }
}


The 'cDealer' character works fine but the 'cBouncer' character seems to just hang at the end of the first animation. Can anyone shed any light on what I'm doing wrong here? It is worth noting that I have also tried this using 'UnlockView' at the end of each if statement and it still doesn't seem to work.

Thanks in advance.

Ben.
Title: Re: Animating Characters Through a Series of Views
Post by: Khris on Tue 22/01/2013 16:03:48
Look at line 8, you're setting timer #3 again instead of #4.
Title: Re: Animating Characters Through a Series of Views
Post by: GoToHellDave on Wed 23/01/2013 13:59:18
Oh dear. I feel like a bit of an idiot. I think it's a case of not being able to see the woods for the trees.