Animate character using current direction?

Started by holden24, Mon 09/10/2006 08:12:56

Previous topic - Next topic

holden24

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?

Ashen

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.
I know what you're thinking ... Don't think that.

holden24

on_key_press:

if (keycode==9) {
character[EGO].LockView(2);
character[EGO].Animate(1);
character[EGO].UnlockView();
}

Ashen

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:
Code: ags

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 entry, for more details on the parameters.
I know what you're thinking ... Don't think that.

holden24

Thanks very much.
I will try it when I get home  :)

SMF spam blocked by CleanTalk