Script problem: If (facing location)

Started by SFG Leader, Fri 14/12/2007 02:03:03

Previous topic - Next topic

SFG Leader

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

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

What code could I use to make this work?

Gilbert

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

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

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

SMF spam blocked by CleanTalk