Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Moox on Sun 25/07/2004 03:58:12

Title: What direction is the character facing?
Post by: Moox on Sun 25/07/2004 03:58:12
Is there a way tell which direction the character is facing? I have searched the forum, manual and variabls but cant find anything.
Title: Re: What direction is the character facing?
Post by: rtf on Sun 25/07/2004 05:17:13
Custom Function Time!Ã,  Ã, :D


function faceback () {
FaceLocation(GetPlayerCharacter(),160,-1000);
}
function facefront () {
FaceLocation(GetPlayerCharacter(),160,1000);
}
function faceleft () {
FaceLocation(GetPlayerCharacter(),-1000,100);
}
function faceright () {
FaceLocation(GetPlayerCharacter(),1000,100);
}

Script Header:

import function faceback ();
import function facefront ();
import function faceright ();
import function faceleft ();



I hope that's what you meant.


EDIT:  Aww, crap.  It wasn't.  Sorry, LT.  Can't help you there.
Title: Re: What direction is the character facing?
Post by: Hollister Man on Sun 25/07/2004 05:27:37
 ;D

Well, its kinda round-about, but it should work.  You should be able to detect which loop the character is using with the character[EGO].loop variable, thus giving you a 'up/down/left/right' direction.  Other than that, it'd be pretty hard, I think.
Title: Re: What direction is the character facing?
Post by: Moox on Sun 25/07/2004 05:49:40
Ill try that hollister, thanks.


Thanks for posting even though that wasnt what I was after rtf.
Title: Re: What direction is the character facing?
Post by: Moox on Sun 25/07/2004 16:53:56
Whats wrong with this script, nothing happens when I use it

//down
if (character[EGO].loop == 0) {
  SetCharacterView (EGO, 2);
  AnimateCharacter (EGO, 0, 1, 0);
ReleaseCharacterView(EGO);

}
//left
if (character[EGO].loop == 1) {
  SetCharacterView (EGO, 2);
  AnimateCharacter (EGO, 1, 1, 0);
ReleaseCharacterView(EGO);

}
//right
if (character[EGO].loop == 2) {
  SetCharacterView (EGO, 2);
  AnimateCharacter (EGO, 2, 1, 0);
ReleaseCharacterView(EGO);

}
//up
if (character[EGO].loop == 3) {
  SetCharacterView (EGO, 2);
  AnimateCharacter (EGO, 3, 1, 0);
ReleaseCharacterView(EGO);

}
Title: Re: What direction is the character facing?
Post by: Gilbert on Mon 26/07/2004 03:40:32
That's because AnimateCharacter() is not a blocking function and you release the views before the animations stopped. You can use AnimationCharacterEx() instead:



//down
if (character[EGO].loop == 0) {
Ã,  SetCharacterView (EGO, 2);
Ã,  AnimateCharacterEx (EGO, 0, 1, 0, 0, 1);
ReleaseCharacterView(EGO);

}
//left
if (character[EGO].loop == 1) {
Ã,  SetCharacterView (EGO, 2);
Ã,  AnimateCharacterEx (EGO, 1, 1, 0, 0, 1);
ReleaseCharacterView(EGO);

}
//right
if (character[EGO].loop == 2) {
Ã,  SetCharacterView (EGO, 2);
Ã,  AnimateCharacter (EGO, 2, 1, 0, 0, 1);
ReleaseCharacterView(EGO);

}
//up
if (character[EGO].loop == 3) {
Ã,  SetCharacterView (EGO, 2);
Ã,  AnimateCharacter (EGO, 3, 1, 0, 0, 1);
ReleaseCharacterView(EGO);

}

Title: Re: What direction is the character facing?
Post by: rtf on Mon 26/07/2004 19:18:23
I have a question-  it's kindof off the topic, and a little newb-ish, but I have been curious.

  If animations and movements don't work if you don't add a Wait() or use a blocking function, then why are they there?  Is there some awesome purpose that I should know about?

Thanks
Title: Re: What direction is the character facing?
Post by: Scorpiorus on Wed 28/07/2004 23:01:08
Quote from: releasethefrogs on Mon 26/07/2004 19:18:23If animations and movements don't work if you don't add a Wait() or use a blocking function, then why are they there?
You can, for example, run multiple animations simultaneously:

AnimateCharacter(EGO, ...);
AnimateCharacter(MAN, ...);
AnimateCharacter(BART, ...);
AnimateObject(0, ...);

while (<any of them is animating>) Wait(1);

ReleaseCharacterView(EGO, ...);
ReleaseCharacterView(MAN, ...);
ReleaseCharacterView(BART, ...);


Also without Wait() you can animate things and let the player to control the character at the same time.