Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Andrea1992 on Thu 09/07/2020 18:29:08

Title: bar level and idle view issue
Post by: Andrea1992 on Thu 09/07/2020 18:29:08
Hi,
I added a "hunger" level bar using Gui's and it's updated each loop in repeatedly_execute function. I followed Gurok tutorial: https://www.adventuregamestudio.co.uk/forums/index.php?topic=54827.0 (https://www.adventuregamestudio.co.uk/forums/index.php?topic=54827.0)

When the hunger level reaches a specific value I want my character to change its idle view, so I'm using SetIdleView function inside the repeatedly_execute function as well.
Code (ags) Select

function repeatedly_execute()
{
  if(hungerLevel== 408)
  {
    cPedro.SetIdleView(71, 0);
  }
}


The bar level is working perfectly, but not the idle view.

The idle view is only changing when I set a delay of 0. It changes to the first frame of the view but doesn't animate. And when I set a different delay it doesn't even change the view at all.

Now, I tested the idle view animation by itself and is working fine when I set it in the character's properties. But is not working in the script above.
I also tested the script using other views that have been animating fine in other scenarios and this didn't help either.

I have no clue how to proceed and make it work. Please help!!  :-D
Title: Re: bar level and idle view issue
Post by: Matti on Thu 09/07/2020 18:46:15
If hungerLevel stays at 408 your script runs every game loop, so the idleview will reset again and again.

Try this:

Code (ags) Select

function repeatedly_execute()
{
  if (hungerLevel == 408 && cPedro.IdleView != 71)
  {
    cPedro.SetIdleView(71, 0);
  }
}
Title: Re: bar level and idle view issue
Post by: Andrea1992 on Fri 10/07/2020 02:17:09
Thanks Matti!  :grin:

Instead of cPedro.IdleView != 71 I used  cPedro.View != 71 and worked perfect. I struggle with debugging.

Have a lovely day/night!
Title: Re: bar level and idle view issue
Post by: Khris on Fri 10/07/2020 08:56:08
Just out of curiosity, what happened when you used cPedro.IdleView != 71?
Title: Re: bar level and idle view issue
Post by: Andrea1992 on Sat 11/07/2020 17:27:29
Hi Khris,
it was not animating nor walking, like stuck updating the idle view.
But that was also my mistake. I had an useless command just below that make it do that.

Then, it worked exactly as Matti suggested.

Cheers