Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: AmOrPhIsSs on Sat 26/10/2013 22:08:21

Title: Different Animations for one character
Post by: AmOrPhIsSs on Sat 26/10/2013 22:08:21
Hi All,

I need help in assigning different animations to the same character.
I want it to move to a certain position on the screen THEN start walking, my code below just ignores the first step and goes walking directly...Can somebody instruct me how to put this code correctly in a room?

 
  cEagle.Move(800, 400, eNoBlock, eAnywhere);
  Wait(1);
  cEagle.Walk(300, 300, eNoBlock, eAnywhere);
 
Title: Re: Different Animations for one character
Post by: Ghost on Sat 26/10/2013 22:41:42
As I see it, calling Move with eBlock should do the trick.
Title: Re: Different Animations for one character
Post by: AmOrPhIsSs on Sat 26/10/2013 22:59:55
Thanks.that did the trick though I don't know why :)
Title: Re: Different Animations for one character
Post by: Crimson Wizard on Sat 26/10/2013 23:22:12
Quote from: AmOrPhIsSs on Sat 26/10/2013 22:59:55
Thanks.that did the trick though I don't know why :)
Manual to the rescue :)
http://www.adventuregamestudio.co.uk/wiki/Understanding_blocking_scripts
Title: Re: Different Animations for one character
Post by: Khris on Sat 26/10/2013 23:36:17
To give a quick explanation:

When a command like .Move or .Walk is executed with the eBlock parameter, the game waits until the object has reached its target before proceeding with the next command. eNoBlock means that AGS continues with the next command immediately afterwards, while the movement happens in the background, at the same time.
If you call two eNoBlock commands on the same entity, the first one is therefore pretty much ignored, because it basically gets "overwritten" by the second one.
Title: Re: Different Animations for one character
Post by: AmOrPhIsSs on Sat 26/10/2013 23:48:26
what if I wanna make 2 animations for the same entity but without blocking the scene ?
How can I manage to do that ?
Title: Re: Different Animations for one character
Post by: Khris on Sun 27/10/2013 00:38:11
You'd have to use a repeatedly_execute function.
The basic idea is to start the first animation, and set a variable. In repeatedly_execute, which is a function called each frame (40 times per second by default), you'd check whether the variable is set but the first animation has stopped. At that point you'd start the second one.

It's simply a way to tell AGS to do something not right now but at some arbitrary point in the future, when some game state has been reached.
Title: Re: Different Animations for one character
Post by: Crimson Wizard on Sun 27/10/2013 01:05:37
Also, if by "animations" you mean moving/walking character, then you can use "Character.Moving" property, for example:

Code (ags) Select

cEagle.Move(800, 400, eNoBlock, eAnywhere);
while (cEagle.Moving)
{
   // keep looping while eagle is moving;
   // calling "Wait" here actually lets the game do other stuff on background
   Wait(1);
}
cEagle.Walk(300, 300, eNoBlock, eAnywhere);


What solution to use depends on what you want to achieve, of course.