Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: SFG Leader on Fri 14/12/2007 02:03:03

Title: Script problem: If (facing location)
Post by: SFG Leader on Fri 14/12/2007 02:03:03
I'm trying to get my character to do something if he is facing a certain
location but I don't know the script for it. I tried searching the help for
it but to no avail.
Pseudo code:

if (character[GEORGE].FaceingLocation (319, 174) == true) {
// My code here
}

What code could I use to make this work?
Title: Re: Script problem: If (facing location)
Post by: Gilbert on Fri 14/12/2007 02:54:39
The Character.FaceLocation() function tells the character to face a location, it is not used to check what location he's facing.

Actually engine only stores the direction a character is facing, not a specific location on screen, so you should only check if he's facing up, down, left or right (if the character's graphics View has diagonal loops you can check if he's facing the diagonal directions as well). For example, if you want to check if your character is facing right:

if (character[GEORGE].Loop==2) { //right
// Your code here
}

You can check from the editor about which loop corresponding to which direction.