[SOLVED] Only two directions for character

Started by Matti, Thu 22/01/2009 20:09:52

Previous topic - Next topic

Matti

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.

Khris

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

Matti

#2
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.

Khris

Did you turn off "Characters turn before walking?"

Matti


SMF spam blocked by CleanTalk