Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Matti on Thu 22/01/2009 20:09:52

Title: [SOLVED] Only two directions for character
Post by: Matti on Thu 22/01/2009 20:09:52
I want my character to look either left or right, but not up and down. If he walks up or down he's supposed to subsequently face the direction he faced before walking. So loop 0 and 3 are only for walking, not for standing.

I really don't know how to solve that problem but it's perhaps because I'm not really concentrated right now.

If it matters: I use the keyboardmovement-module (that comes with AGS) and disabled the cursor.
Title: Re: Only two directions for character
Post by: Khris on Thu 22/01/2009 20:43:26
Create a second view and put the existing walk cycle sprites for left and right in there.
Then change the first view's up and down sprites to the left sprites (LEFTVIEW), the second view's up and down sprites to the right sprites (RIGHTVIEW).

In rep_ex, add:
  if (!player.Moving) {
    if (player.Loop == 1 && player.NormalView != LEFTVIEW) player.ChangeView(LEFTVIEW);
    if (player.Loop == 2 && player.NormalView != RIGHTVIEW) player.ChangeView(RIGHTVIEW);
  }


The constant switching of views should be unnoticeable and shouldn't interfere with walking.
Title: Re: Only two directions for character
Post by: Matti on Fri 23/01/2009 14:58:17
Thanks, that almost works perfectly.


There are just two small things:

1. If the character looks to the left and then goes down he briefly looks right before walking

And the exact opposite:

2. If the character looks to the right and then goes up he briefly looks left before walking


EDIT: Well, I'm almost certain this has to do with other lines of the script. I'll look into it and post the code if I'm not able to get rid of that small problem.
Title: Re: Only two directions for character
Post by: Khris on Fri 23/01/2009 16:32:25
Did you turn off "Characters turn before walking?"
Title: Re: Only two directions for character
Post by: Matti on Fri 23/01/2009 17:08:16
Ah, thanks, that did the trick.