Hello,
I've been trying for some time to figure out a way to get my main character to have multiple idle views. SSH's Idle Module looked promising, but because of some major glitches that I was unable to solve, I've tried to come up with an alternative system.
Here's what I've come up with -- I've put a variable named "IdleTimer" at the top of the Global script and placed this code under repeatedly_execute:
if (player_idle==true && player.Animating==false) {
IdleTimer++;
if (IdleTimer>=300) {
if (player.View==36) {
player_idle_sm(); //small svga
}
//other if statements will follow once I've got this working
}
}
And this is what player_idle_sm looks like:
function player_idle_sm() {
int RandomIdle=Random(3);
if (RandomIdle==0) {
player.SetIdleView(171, 4); //idle1
IdleTimer=0;
}
else if (RandomIdle==1) {
player.SetIdleView(171, 4); //blink1
IdleTimer=0;
}
else if (RandomIdle==2) {
player.SetIdleView(174, 4); //idle2
IdleTimer=0;
}
else {
player.SetIdleView(172, 4); //blink2
IdleTimer=0;
}
}
The way this all works is that I have IdleTimer work as a sort of "pseudo-timer": its value keeps increasing as long as player_idle is set to true and the player isn't animating, and once it reaches 300, one of several idle views is selected at random, then IdleTimer is reset to 0.
This system works very well except for one noticeable problem. For some bizarre reason, if my character is idling in a diagonal position, after a few idle animations, she will suddenly face up, down, left or right. I can't figure out why this keeps happening, or how to fix it.
Does anyone have any idea what's going on?
Thanks in advance!
Hi
Do you have idle views for diagonals as well as up down left right.... if this be the case.
barefoot
Yes, I have diagonal loops for all the idle views.
Well, I seem to have solved this problem on my own.
Two of the idle views I'm using have around 10 frames per loop, but the two "blink" views have only 1-3 frames per loop (since they just animate the character blinking). For some reason, only these views would cause my character to face up, down, left or right if the character was standing at a diagonal angle when the blinking idle animation began.
I decided to try adding several more frames to the blinking loops so that they were roughly equal to the loops from the other idle views, and surprisingly, this fixed the problem. I have no idea why having too few frames per loop would make AGS behave this way, but I seem to have fixed this problem.
This sounds like a bug, I'd post it in the 3.2.1 thread:
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=43214.0
I imagine AGS "gets confused" when trying to change the view but not the loop & frame and notices that the frame doesn't exist so it defaults back to one of the first four loops or something like that.