Trouble with idle animations

Started by The Creator, Thu 12/01/2012 20:54:43

Previous topic - Next topic

The Creator

I was trying to have a ncp in the background that animates all the time, till you talk to him and then changes the animation loop for the talking one.

I searched a bit the forum and some threads suggested that i should use the IdleView propertie, so i went there and set the first animation as the idle one.

When i run the game, the character does not animate, i stared at the screen for like 2 mins and nothing happened.

I thought that maybe that propertie only worked with the cEgo, so i tried using IdleView too, but i have the same problem, nothing happens.


Do ihave to call some other function? I tried setting the idle view in the room's script but the npc must be referenced or something =X

Ghost

Straight from the manual:

Setting DELAY to 0 causes the idle view to be looped continuously when the character is not moving - this is useful when for example the character is swimming and they need to tread water when idle.
So you need to use CHARACTER.SetIdleView(THEVIEW, 0)


NOTE: Due to a quirk in AGS, you cannot set the Idle View to view 1. In the unlikely event that you created your idle view in View 1, you'll need to move it to another view number.
Another caveat, you can't have an idle view in View1, and if you did that, it will not work.

steptoe

#2
Hi



You may just have 2 views for the NPC: (You can have as many as you like but see events panel)

1: Normal Walking View (Could be your Background animate View containing animation)
2: Talking View

Number 1 View will contain the animation you NPC does (normally used walking)
Or just change to another view.

example using usual Views:

cEgo.Animate(0, 3, eRepeat, eNoBlock); This plays loop 0 of his normal view.

When you talk to him he should go to his Talk View.

Afterwhiich he should return to his Normal animating View.

Idle view is if he is doing nothing at all and after a set time his view will go to Idle.



It's not over until the fat lady sings..

Ghost

#3
steptoe: You describe the "normal use". All correct, but:

Quote from: The Creator on Thu 12/01/2012 20:54:43
I was trying to have a ncp in the background that animates all the time

Khris

The Creator:
Is the function in which you set the IdleView executed at all? Maybe this is just a linkage problem.
Just put a Display("test"); below the command and make sure.

steptoe:
It's nice that you want to help but I'm afraid you are rather misleading newbies than helping them. I've seen this in several threads. In my very own personal opinion, you aren't ready to give advice on coding problems. Sorry.

The Creator

#5
Thanks.

I've tried creating a new view, and using 2 instead of 1 and it worked. I also created a third one so that i can talk to him and he changes animations.

But i've some doubts, in the cEgo the character has 5 or 6 loops, and depending on what it is needed to be displayed the animations changes. Is there a way that i can do the same with the npc? If i use "CHARACTER.SetIdleView(THEVIEW, 0)" i can only set the view i want, but not the loop =x.

EDIT: i've yet to write the function that changes back from the talking animation to the idle one, i've seen that there is a function that is called every frame of the game " repeatedly_execute() ", would you recommend having one little if checking if the player is talking to that character to change it back, or would you suggest something better?

I've noticed that in the cEgo's views there is a space for talking views, is there anyway that i can put some sprites in there and the engine makes all the idle to talking and talking to idle changes by itself?

Ghost

The loops in a view are tied to the direction the character is facing- loop 1 is "down", loop 2 is "left" etc. (It's actually written just right of the loop number)
So when a character faces a certain direction (for example, while walking to a place), the proper loop will be used, and only that loop.

You can use the command CHARACTER.FaceLocation(x,y) to directly change the facing.
Alternatively you can use CHARACTER.FaceCharacter and CHARACTER.FaceObject.

These topics are described in the manual in good detail; so I won't copy an example here ;)

Khris

Quote from: The Creator on Fri 13/01/2012 20:59:50I've noticed that in the cEgo's views there is a space for talking views, is there anyway that i can put some sprites in there and the engine makes all the idle to talking and talking to idle changes by itself?

Yes, usually you'd put together the views, assign them to the character and the engine should take care of the rest. There's no need to manually change from idle to talking; as soon as you make the character say something, the talking view is used automatically, and when finished, the character switches back to their idle view.

Creator

Sorry, I don't have anything to add, but:
My name! You stole my name!  :o

The Creator

When i saw your nickname i thought exactly the same hahahaha.

I tried using the speech viewm and it's working just fine. I've also put the correct view in the idleview but i still have to call the CHARACTER.setIdleView function in the game_start() function from the global script to make the idle animation work.

If i do that the npc idle-animates, changes to speech view when i talk to him and goes back to idle when i'm done.


There's only one little thing; when i'm talking and he's listening, he does the idle animation instead of remaning in the first frame completely still. It's this because he has 0 delay for the idle animation??

Khris

Quote from: The Creator on Mon 16/01/2012 20:22:45I've also put the correct view in the idleview but i still have to call the CHARACTER.setIdleView function in the game_start() function from the global script to make the idle animation work.

No you don't, but AGS uses a default delay of something like 15 seconds so it takes a while. If you need a shorter delay, then yes, you have to set the IdleView manually.

Quote from: The Creator on Mon 16/01/2012 20:22:45There's only one little thing; when i'm talking and he's listening, he does the idle animation instead of remaning in the first frame completely still. It's this because he has 0 delay for the idle animation??

Technically, there's no such thing as "listening" here. AGS has no way of knowing who your player character is talking to, so how would AGS know to disable the IdleView while the player is talking, regardless of the delay?
An easy fix is to disable the IdleView in the @S part of the dialog and turn it back on before any stop commands.

The Creator

Yes i know, but i thought that using "listening" was a very graphic description so i used it.

Thanks, i'll try setting the animation from the dialog script.

Khris

It doesn't matter that you used it as graphic description; it sounded like you expected the other character to not idle animate during a dialog (also indicated by using "??") and I simply tried to clarify that there's no difference whatsoever between an NPC who is involved in a dialog and one who isn't.

The Creator

Yes, i was indeed asking if the engine knew who i was talking and if i had already finished talking.

I could set another idle animation for the character to look like he's listening, got a bit trickier with the tab space for the scripts to work but after 5 o 6 times of reading the manual i could manage to do exactly what i wanted :)




Thank you very much, you may close the thread now.

Filipe

Hello again, and sorry to revive this old post.

I want to put my idle view on a loop. I know that if I set it to Zero it loops the idle view - Character.SetIdleView(4 ,0) - , however I don't want it to start immediately, only after 4, or 5 seconds delay... How can I solve this issue?

Thanks :)

Matti

Just set a timer and when it's expired, set the idle view.

If it's supposed to happen in one room, set the timer in room_load. If there's supposed to be a delay everytime the player enters that room, set the idle view to -1 in room_load.

Filipe

#16
Thanks for replying MAtti :)

How do you do the timer? With a variable?

I want the same kind of effect, as with Super MArio 64, where first he starts looking around, than he yawns, and finally he drops to the floor and starts sleeping (than it loops this last idle view forever)... Can you help me with the code? Do I need to use global variables? Where should I put the timer?

So, I do 3 idle views, and than it repeats the first idle view like 3 times (character looks around), after this it repeats the second idle view another 3 times (he yawns), and finally he repeats the 3th idle view, forever...

Help me please? :(

Thanks :)

Cassiebsg

#17
use a if/else

Code: ags


int optionIdle=0;

void IdleOptions();
{
 if (optionIdle<3 && isTimerExpired) 
 {
    /// 
    optionIdle++;
    startTimer(); //not real code
  }
  if else  (optionIdle>=3 && optionIdle<6 && isTimerExpired)  // think it might also work with (6<optionIdle>=3) but haven't tried it
  {
    /// set to idle 2
    optionIdle++;
    startTimer(); //not real code
  }
  if else (optionIdle==6)
  {
    /// set to idle 3
    optionIdle++; // this will ensure the counter moves to 7 and this function won't be true again 
  }
}


Then call this function in Global scripts repeat_execute.

EDIT: Wait, this needs another kind of check or it won't run... Like something to detect the idle has started, or you just use a home made timer that counts the time that the player hasn't clicked anything.

Sorry it's not a copy/paste code, but hopefully it'll be enough to get you in the right track
There are those who believe that life here began out there...

Matti

#18
Hm... I noticed that working with (different) idle views isn't very convinient, especially as can't just check if the player is being idle and for how long.

If I understand you right the three different idle views are supposed to happen one after the other. I tested around a bit and haven't been able to repeat the first idle views 3 times and then have the last one loop endlessly. But I came up with this. The problem is that you need to set the timer exactly so that it matches the time it takes to loop the idle views three times.

Create a global int called idle_timer = 200 (or how long it should take for the first idle view to begin). With normal gamespeed (40 fps), this would mean 5 seconds.
In my code the three idle views are 5,6,7.

Then put this in the global script:

Code: ags

// in game_start:
player.SetIdleView(-1, 0);

// in on_event: (create one if there is none)
function on_event(EventType event, int data) 
{
  // reset timer and view on every room change
  if (event == eEventEnterRoomBeforeFadein) {
    player.SetIdleView(-1, 0);
    idle_timer = 200;
  }
}

// in repeatedly_execute()
  if (idle_timer > 0)
  {
    idle_timer --;
    if (idle_timer == 0)
    {
      if (player.IdleView == -1) 
      {
        player.SetIdleView(5, 0);
        idle_timer = 200; // or how long idle view 5 should be played
      }
      else if (player.IdleView == 5)
      {
        player.SetIdleView(6, 0);
        idle_timer = 200; // or how long idle view 6 should be played
      }
      else if (player.IdleView == 6) player.SetIdleView(7, 0);
    }
  }
  
  // reset the idle view when the player is moving
  if (player.Moving)
  {
    player.SetIdleView(-1, 0);
  }

  // reset timer when the player stands still and no idle animation is running
  if (!player.Moving && !player.Animating && idle_timer == 0)
  {
    idle_timer = 200;
  }

Filipe

#19
Tanks Matii again (Also thanks to Cassiebsg) :). It is perfect. When I said 3 times, it was just an example, it could be more, it could be less...what I meant was that it stayed in the same idle a certain amount of time, and then moved to the next one :)

I'm gonna tried it. I'm still doing the animations... which is giving me some hard work :(. I just which there were some sort of plug in for photoshop that turned into pixel art/cartoon, whatever image we given it :(

I know C, and c++. My doubt is if you can use it as you like, on AGS... like, creating whatever variables you want, using switch - case, etc..

That's what I had in mind...

On Thimbleweed park, there is this idle position (player blink eyes) every time the character arrives to the destination, that we had clicked...

I wanted this to happen, so the first idle view would start instantly... than, if player.moving==false, it started a second idle position, and then the last idle position, but this time, forever (character falls on the floor sleeping, like Super Mario ;) in your case it would be idle view 7)... then when the player starts moving again, it will reset the whole cycle

So your code seems right on spot :)

Remember? (here he is dreaming with italian food...ah spaggeti..ah raviolli... ah mama mia..LOLOL) :)

https://www.youtube.com/watch?v=hvjkre5ycCc



SMF spam blocked by CleanTalk