Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Theme on Sun 31/07/2005 15:22:31

Title: character not facing the right location [SOLVED]
Post by: Theme on Sun 31/07/2005 15:22:31
I use
player.FaceLocation(x,y);
and at some random places the character doesn't face the right location

o/
Title: Re: character not facing the right location
Post by: DoorKnobHandle on Sun 31/07/2005 15:25:13
Could you give some more code? When does this occur?

Are you sure you don't mix up x and y?
Title: Re: character not facing the right location
Post by: strazer on Sun 31/07/2005 16:03:59
Keep in mind that FaceLocation expects screen coordinates, so if you have a scrolling room, you have to substract GetViewportX and GetViewportY from room coordinates (object coordinates, character coordinates, hotspot walk-to points etc.):

  player.FaceLocation(oDoor.X - GetViewportX(), oDoor.Y - GetViewportY());
Title: Re: character not facing the right location
Post by: Theme on Sun 31/07/2005 18:28:55
i have a scrolling room
i tryed:

guicoinmouseclickx = mouse.x;
guicoinmouseclicky = mouse.y;
and then
player.FaceLocation(guicoinmouseclickx-GetViewportX(),guicoinmouseclicky-GetViewportY());

but it didnt work

o/
Title: Re: character not facing the right location
Post by: strazer on Sun 31/07/2005 22:59:09
Mouse coordinates already are screen coordinates, so you don't have to substract the viewport position for them. Ignore my suggestion then.

To quote [...]:
QuoteCould you give some more code? When does this occur?
Title: Re: character not facing the right location
Post by: Theme on Mon 01/08/2005 23:31:14
it worked now:

player.FaceLocation(GetViewportX()+mouse.x,GetViewportY()+mouse.y);

mouse gets screen coordinates and facelocation uses room coordinates
thanks for the help

o/
Title: Re: character not facing the right location
Post by: strazer on Tue 02/08/2005 05:41:29
Quotefacelocation uses room coordinates

Not according to the manual, but you're right, it does. Good work!