Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: SpacePaw on Mon 14/06/2010 17:49:22

Title: [SOLVED]FaceDirection diagonals problem?
Post by: SpacePaw on Mon 14/06/2010 17:49:22
Hello,
I have no idea why I can't get the character to face diagonal directions with FaceDirection :/ He always ends up looking up/down/left/right

function FaceDirection (this Character*, Directions direction, BlockingStyle block)
{
 if (direction == eUp)
 {
   this.FaceLocation(this.x, this.y-1, block);
 }
 else if (direction == eDown)
 {
   this.FaceLocation(this.x, this.y+1, block);
 }
   else if (direction == eLeft)
 {
   this.FaceLocation(this.x-1, this.y, block);
 }
   else if (direction == eRight)
 {
   this.FaceLocation(this.x+1, this.y, block);
 }
   else if (direction == eUpLeft)
 {
   this.FaceLocation(this.x-1, this.y-1, block);
 }
   else if (direction == eUpRight)
 {
   this.FaceLocation(this.x+1, this.y-1, block);
 }
   else if (direction == eDownLeft)
 {
   this.FaceLocation(this.x-1, this.y+1, block);
 }
   else if (direction == eDownRight)
 {
   this.FaceLocation(this.x+1, this.y+1, block);
 }
}


Here's the function code...I tried increasing 1 to 50 thinking that maybe engine got confused by small values but it didn't help. Suggestions?
Title: Re: FaceDirection diagonals problem?
Post by: Khris on Mon 14/06/2010 18:10:12
The only reason I can think of: I believe a character can only face directions they can walk in. Is the character on a walkable area?
Title: Re: FaceDirection diagonals problem?
Post by: SpacePaw on Mon 14/06/2010 18:14:13
Quote from: Khris on Mon 14/06/2010 18:10:12
The only reason I can think of: I believe a character can only face directions they can walk in. Is the character on a walkable area?

Well yes he is...on the very edge of it. I tried all possible face directions and he can face all except the diagonals (even the ones facing the way he came from)
Title: Re: FaceDirection diagonals problem?
Post by: adm244 on Mon 14/06/2010 18:25:45
[deleted]
Title: Re: FaceDirection diagonals problem?
Post by: SpacePaw on Mon 14/06/2010 18:53:50
Quote from: adm244 on Mon 14/06/2010 18:25:45
SpacePaw, You did't try to go simple path?
Simply having substituted the sprite of the character when it is necessary to turn it :)

Unfortunately the character actually needs to rotate himself from current position to new one. Simple swap won't work here.
Title: Re: FaceDirection diagonals problem?
Post by: Wyz on Mon 14/06/2010 19:01:28
Make sure every loop in the walk view has at least two frames, just duplicate the first frames if you need to.
I hope that helps you. :)
Title: Re: FaceDirection diagonals problem?
Post by: SpacePaw on Mon 14/06/2010 19:07:40
Quote from: Wyz on Mon 14/06/2010 19:01:28
Make sure every loop in the walk view has at least two frames, just duplicate the first frames if you need to.
I hope that helps you. :)

Thanks! It works now! I had separate 1 frame view for turning :) it solved it! You rock!