Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Construed on Thu 16/01/2014 01:02:47

Title: 2 random animations from same view
Post by: Construed on Thu 16/01/2014 01:02:47
Nevermind, ill just figure it out when im feeling better.......
Title: Re: 2 random animations from same view
Post by: monkey0506 on Thu 16/01/2014 19:28:40
Not sure exactly what you were looking for, but...

Code (ags) Select
cEgo.LockView(RANDOMATION);
int loop = Random(Game.GetLoopCountForView(RANDOMATION) - 1);
cEgo.Animate(loop, 5, eOnce, eBlock);
cEgo.UnlockView();


This would select a random loop from the view and animate the character. Since you deleted the post, it's not clear what you were looking for, but I'll leave this here in case it helps.
Title: Re: 2 random animations from same view
Post by: Construed on Fri 17/01/2014 03:46:05
I was looking for a way to make random animations come from different loops of the same view for an object. "NPC"
Without the animations interrupting each other or causing an ugly twitching effect.
"Basically a blacksmith looking around and touching his beard."
I came up with this:

Code (ags) Select

int ran=Random(5);

if (object[1].Animating) return;

if (ran==3) object[1].Animate(0, 6, eOnce, eNoBlock);

if (ran==1) object[1].Animate(1, 15, eOnce, eNoBlock);

if (ran==0) object[1].Animate(0, 75, eOnce, eNoBlock);



Which has worked surprisingly good!

I thank you for having the patience to respond to the post anyway as I was having a really bad and depressed day.

I'm certain I will also use the code you provided for other situations so I thank you greatly for the code my friend!
As always it's perfect!