Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: holden24 on Mon 09/10/2006 08:12:56

Title: Animate character using current direction?
Post by: holden24 on Mon 09/10/2006 08:12:56
In 1213, he shoots with Tab, but he shoots both ways.
When I script my character to attack with Tab he only attacks 1 way.
Can someone please help me?
Title: Re: Shooting with one button?
Post by: Ashen on Mon 09/10/2006 11:21:19
What code have you got so far? Since it sounds like you've got it part way working, it'd be easier for us to help if we culd see that, rather than have you start over again.
Title: Re: Shooting with one button?
Post by: holden24 on Thu 12/10/2006 10:04:30
on_key_press:

if (keycode==9) {
character[EGO].LockView(2);
character[EGO].Animate(1);
character[EGO].UnlockView();
}
Title: Re: Shooting with one button?
Post by: Ashen on Sun 15/10/2006 14:06:09
Wait, what was the problem again? That the 'attack' always faces the same direction, whichever way the character is facing? Sorry, misunderstood originally.

The problem is this line:
character[EGO].Animate(1);

Which will always run the same animation (the left-facing loop). Since I don't think LockView affects the loop, replacing that code with:

if (keycode==9) {
  cEgo.LockView(2);
  cEgo.Animate(cEgo.Loop, 3);
  cEgo.UnlockView();
}


Should do it. Note that you were also missing the required 'delay' parameter for Character.Animate - I've used 3, but play around with that until it looks right for you - and that you should realy make it blocking, so the view doesn't release before the animation completes. Read the manual (http://www.adventuregamestudio.co.uk/manual/Character.Animate.htm) entry, for more details on the parameters.
Title: Re: Shooting with one button?
Post by: holden24 on Thu 19/10/2006 05:50:35
Thanks very much.
I will try it when I get home  :)